Latest Posts On Code Maze

Performance Testing of ASP.NET Core APIs With k6

Performance Testing of ASP.NET Core APIs With k6

In this article, we are going to discuss how to do ASP.NET Core Performance Testing, specifically with the open-source tool k6. We'll cover the need for performance testing, how to get the best results, and then dive into some examples of how k6 can help. [sc...

Path Class in C#

Path Class in C#

When we want to perform operations on path strings containing file or directory path information, the best choice is to call the built-in C# Path Class methods. This class comes under the System.IO namespace and System.Runtime.dll assembly. In this article, we are...

What is the Difference Between a DTO and a POCO?

What is the Difference Between a DTO and a POCO?

In this article, we are going to learn the differences between a DTO (Data Transfer Object) and a POCO (Plain Old CLR/C# Object). We use these types of objects in everyday coding. However, we are often not sure what the real differences are. We are going to dive...

Counting Occurrences of a Char Within a String in C#

Counting Occurrences of a Char Within a String in C#

In this article, we are going to learn how to count occurrences of a char within a string in C#. A string is a sequence of characters and we essentially iterate over it to count the number of occurrences of any character within it. [sc name="github"...

Using Query String Parameters with Minimal APIs

Using Query String Parameters with Minimal APIs

In this article, we are going to explain how we can work with query string parameters in Minimal APIs in .NET 6. You may refer here for a nice introduction to the concept of Minimal APIs. Also, we will show new improvements that .NET 7 brings to the table. [sc...

AutoMapper vs Mapster in .NET

AutoMapper vs Mapster in .NET

In this article, we are going to compare the popular object mapping libraries AutoMapper and Mapster. Later, we'll do a performance benchmark to find the most performant one. [sc name="github"...

What is NullReferenceException in C#?

What is NullReferenceException in C#?

In C#, a NullReferenceException occurs when we try to access a variable whose value has not been set or has been set to null. It can be easy to trigger this exception accidentally, so it's important to be aware of how to avoid it in the first place. In this article,...

FileSystemWatcher in C#

FileSystemWatcher in C#

.NET provides a handy way to deal with monitoring different file system changes. In this article, we will discuss what FileSystemWatcher is, how to set it up, and how to configure it to observe various file system changes. In addition, we will take a look at the...

Indexers in C#

Indexers in C#

In this article, we are going to learn about Indexers in C#, how to declare them in a class, struct, or interface, and overload them. We're also going to learn what the differences between indexers and properties are. [sc name="github"...

Return File in ASP.NET Core Web API

Return File in ASP.NET Core Web API

In this article, we are going to learn how to return a file in an ASP.NET Core Web API and some concepts behind it. That said, we are going to implement a simple Web API to read a local file and return this file to download. [sc name="patreon-source-code"...

Improving Unit Tests with Fluent Assertions

Improving Unit Tests with Fluent Assertions

Unit tests are usually a must-have part of building and maintaining a software application. Fluent Assertions is a wonderful library of extension methods. Due to the nature of the library, the code reads like a written sentence. In this article, we will review many...

Feature Flags in ASP.NET Core

Feature Flags in ASP.NET Core

Being able to conditionally enable or disable features in our applications without redeploying our code is a powerful tool that we can take advantage of to quickly iterate on new features in our applications. In this article, we are going to learn about Feature Flags...

Any() vs Count() in .NET: Which One is Better?

Any() vs Count() in .NET: Which One is Better?

In this article, we are going to learn the main differences between Any and Count methods from LINQ. We work with different collections in C# all the time, and we often need to check if there are any records inside the collection or if it is empty. Both methods can...

How to Test a REST API with .NET and xUnit

How to Test a REST API with .NET and xUnit

In this article, we are going to cover how and why we should test a REST API with .NET and xUnit. We'll discuss why this is important, and how to actually test various components of an API response to ensure requirements are being met. [sc name="github"...

Using Generics in C#

Using Generics in C#

Generic programming is a powerful tool that C# offers to developers. In this article, we'll take a look at how generics work in C# and some of the benefits they provide. We'll also see how to use generics with classes, methods, and delegates. Finally, we'll look at...