Tracing .NET Applications Easily With OpenTelemetry
One of the fundamental concepts in the OpenTelemetry project is the ability to observe end-to-end requests through our applications, which is known as tracing. We achieve this by adding custom code to our .NET applications to emit this tracing information, which we...
Realistic Data Generation in .NET With Bogus
In this article, we are going to learn what Bogus library is and how we can use it to generate fake data in .NET. We will create examples for generating data in different ways and show some additional community extensions we can use on top of Bogus. [sc name="github"...
Required Members in C#
C# 11 introduces the concept of required members. Any code instantiating the containing class must initialize these members; otherwise, the compiler will issue an error while compiling it. In this article, let's learn how to use this feature to prevent bugs and catch...
How to Randomize a List in C#
C# has several built-in methods for working with arrays and lists, but what if you need to randomize a list of items? In this article, we'll look at some techniques we can use to randomize lists in C#. We'll also discuss some of the pros and cons of each technique and...
How to Get The List of Properties in C#
In this article, we are going to learn how to get the list of properties in C#, and also how to use the BindingFlags to filter the properties to retrieve. [sc name="github"...
How to Resolve Non-nullable Property Must Contain a Non-null Value Warning
When compiling a C# application, we may see the warning "Non-nullable property must contain a non-null value when exiting constructor. Consider declaring it as nullable." This article explains why we encounter this warning and what we can do to resolve it. [sc...
Convert String and Int to Enum in C#
In this article, we’re going to look at how to convert a string and int to an enum in C#. Enums allow us to declare a group of related constant values in a readable way where the underlying data type is usually an integer. [sc name="github"...
Understanding PLINQ in .NET
In this article, we are going to explore PLINQ, which is the parallel implementation of LINQ. We are going to focus on when, and how to efficiently use it. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/csharp-linq/UnderstandingPLINQ"...
Boxing and Unboxing in C#
In this article, we are going to talk about boxing and unboxing in C#. When we work with C# language constantly, we need to...
Encrypting and Decrypting a String in C#
In this article, we will learn how encrypting and decrypting a string is done using C# and the Cryptography package that comes included with .NET. [sc name="github"...
Cryptography Implementations in .NET
Cryptography is the security backbone of what our modern society is built upon. This science has enabled us to keep data and communication safe from being compromised or stolen. We can find examples of its use in personal password managers up to the security aspect of...
Generic Attributes in C#
In this article, we are going to learn how generic attributes help us implement better custom attributes through a practical example. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/csharp-advanced-topics/GenericAttributesInCSharp"...
Rebus in .NET – Service Bus Implementation
When working with distributed applications that need to asynchronously communicate with each other, the "Publish-Subscribe" pattern is very common. To avoid being tightly coupled to a message broker, such as RabbitMQ, we use an abstraction layer, known as a service...
How to Iterate Over JSON Objects in C#
Manipulating JSON objects is a common operation in applications. In this article, we will look at different ways of iterating over JSON objects in C#. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/json-csharp/IteratingOverJsonObject"...
OpenTelemetry in .NET – Basic Usage With Examples
Being able to debug our applications in an efficient manner is a very important aspect when it comes to designing and building applications. In a world of microservices, it becomes harder and harder to reason about our applications and where the source of a bug or...
ConcurrentBag in C#
In C#, there are many classes that we can use to represent a group of objects that we may manipulate concurrently using multiple threads. One such class is the ConcurrentBag<T>. In this article, we will learn how to add, access, and remove elements from a...
How to Add a BearerToken to an HttpClient Request
Often, in our daily routine, we have to deal with secure APIs and use a BearerToken to make HTTP requests. In this article, we are going to learn the correct way to add a BearerToken to an HttpClient request. [sc name="patreon-source-code"...
Understanding Task and ValueTask in C#
If we want to optimize our code and improve the performance of our app, there is no one go-to solution. Instead, we analyze our code and try to find where to improve. Understanding Task<T> and ValueTask<T> in C# is essential because using them correctly...
Different Ways to Use Select Tag Helper in ASP.NET Core
In this article, we are going to learn about the select tag helper and its various uses. We are going to start with a brief overview of what exactly tag helpers in ASP.NET Core are and then proceed to learn more about the select tag helper. [sc name="github"...
How to Update the Value Stored in a Dictionary in C#
In this article, we'll be looking at ways to update a value stored in a dictionary. A dictionary is a class in C# that allows us to store a collection of key/value pairs in a strongly typed way. [sc name="github"...
Default Interface Method in C# And When to Use It
In this article, we will learn about default interface methods in C#. So, let's start. Introduction to a Default Interface Method The...


