Health Checks in ASP.NET Core
In this article, we are going to look into Health Checks in ASP.NET Core. Then we are going to look into the Health Checks Middleware provided by ASP.NET Core to create some checks and add a nice dashboard to view all our Health Checks. Finally, we will briefly look...
How to Sum Up Elements of an Array in C#
A frequent question in .NET interviews is about operations using arrays. In this article, we are going to learn how to sum up elements of an array in C#. After studying the different techniques, we are going to build a performance benchmark and check which one is the...
Using Variables Inside Strings in C#
In this article, we are going to explore how to use variables inside strings in C#. There are a few ways to accomplish that, depending on the C# version being used. To download the source code for this article, you can visit our GitHub...
Merge Sort in C#
Merge sort in C# is one of the algorithms that we can use to sort elements. Merge Sort is known to be efficient as it uses the "divide and conquer" strategy that we are going to discuss as we implement it. To download the source code for this...
How to Deserialize a Complex JSON Object in C# .NET
Serializing and deserializing JSON objects are an important part of all software engineer routines. In this article, we will learn different techniques about how to deserialize a complex JSON object in C# and check, with a performance benchmark, which is the fastest...
Types of Inheritance In C#
In this article, we are going to describe the types of inheritance in C# and their use in various scenarios. Let's dive in. What is Inheritance in C#? The...
How to Remove Elements From a Generic List in Iteration With C#
In this article, we are going to look at different ways to remove elements from a generic list while iterating through it. If we try simply to do a test and...
Serialize Enum as String in C#: JsonStringEnumConverter
A C# enum serializes as a number by default. To get its name instead, System.Text.Json takes a JsonStringEnumConverter and Newtonsoft.Json takes a StringEnumConverter, applied to one property, one enum type, one serializer call, or the whole application....
Queue in C#
Queue in C# is a very useful collection for the data which we need to handle with first-in, first-out order. In this article, we are going to cover the main concepts of Queues in C#. To download the source code for this article, you can visit our...
C# 10 New Features
In this article, we are going to take a look at what's new in C# 10. .NET 6 supports the latest C# version, and to use it in our projects, we will need the latest .NET 6 SDK or Visual Studio 2022 which includes the SDK. To download the source code...
How to Write a Byte Array to a File in C#
Writing a byte array to a file in C# is one call: File.WriteAllBytes() takes a path and the bytes, creates or truncates the file, writes, and closes it. The other approaches exist for the cases that one call does not cover: appending instead of replacing, writing...
How to Add Parameters to a String in C#
In this article, we are going to learn how to add parameters to a string in C# in a few different ways. Let's start Using String.Format() Method Firstly, we can...
Array Slicing in C#: How to Get a Subarray
Array slicing is how we take a contiguous run of elements out of an array, and the result is what most of us call a subarray. Since C# 8 one expression does it: numbers[1..4] returns the elements at indices 1, 2 and 3. That is not the only way, and the others are not...
Custom Attributes in C# and .NET
A custom attribute in C# is a class that derives from System.Attribute and gets applied in square brackets to a type or a member. The compiler writes it into the assembly's metadata, where it sits until something reads it back with reflection. Using one takes three...
Introduction to Unit Testing With NUnit in C#
In this article, we are going to learn about unit testing with NUnit in C# through examples. Testing is one of the essential parts of the software development cycle, and there are many different test types. We'll concentrate our attention on programmatic tests, such...
How to Convert String to Int in C#
In this article, we are going to talk about how to convert string to int in C#. Int is an alias of Int32, and defines an integer number in range from -2,147,483,648 to +2,147,483,647. Setting a value of an int variable that is out of this range, will produce a "System...
Bubble Sort In C#
Sorting arrays is quite a common problem in programming. The bubble sort algorithm is simple to implement as it involves comparing adjacent elements and swapping them when they are in the wrong order. We are going to learn how Bubble Sort in C# works. [sc...
Iterate and Loop Through a Dictionary in C#
A foreach loop is how we iterate a Dictionary<TKey, TValue> in C#. Each pass hands us one KeyValuePair<TKey, TValue>, and the shortest way to read it is to deconstruct it in the loop header: foreach (var (key, value) in monthsInYear). To...
Task.Factory.StartNew vs Task.Run in C#: The Difference
Use Task.Run. It is Task.Factory.StartNew with the two defaults almost every caller wants: TaskScheduler.Default instead of the current scheduler, and DenyChildAttach instead of allowing child tasks to attach, plus unwrapping for async delegates. Task.Factory.StartNew...


