Latest Posts On Code Maze

Alternative Way of Logging With OpenTelemetry Logging in .NET

Alternative Way of Logging With OpenTelemetry Logging in .NET

One of the most well-known debugging tools for developers is undoubtedly application logging, which allows us to record timestamped information about the current state of our application. In the OpenTelemetry project, logs are the third and final pillar of...

How to Find the Caller Method in C#

How to Find the Caller Method in C#

In this article, we will learn how to find the caller method in C#. We will also learn about scenarios in which this information could be useful and how to retrieve it. [sc name="github"...

How to Serialize a List to JSON in C#

How to Serialize a List to JSON in C#

JavaScript Object Notation (JSON) is widely used for storing, transmitting, and communicating data across different systems and applications. Its simple syntax and ability to represent complex data structures make it an ideal choice for web services and APIs. To...

Testing Exceptions in MSTest, NUnit, and xUnit

Testing Exceptions in MSTest, NUnit, and xUnit

In this article, we will take a look at testing if our code throws exceptions, why we want to do that, and how to do it in the MSTest, NUnit, and xUnit frameworks. [sc name="github"...

TimeSpan in C#

TimeSpan in C#

Creating robust applications and solutions that can stand the test of time requires using complex dates and timespans to ensure accuracy. C# offers a robust TimeSpan structure that allows developers to easily manipulate dates, durations, and ranges. In this article,...

How to Read Connection Strings in .NET

How to Read Connection Strings in .NET

 In this article, we will learn how to read database connection strings from different configuration sources in .NET applications. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/aspnetcore-features/HowToReadConnectionStringsInDotNet"...

How to Read and Parse a JSON File in C#

How to Read and Parse a JSON File in C#

When we develop software applications, we use JSON (JavaScript Object Notation) as a data interchange format, therefore we need to understand how to read and parse JSON files. In this article, we are going to explore six distinct ways to read and parse a JSON file in...

IEnumerable, ICollection, IList and List – Which One To Use?

IEnumerable, ICollection, IList and List – Which One To Use?

In this article, we will learn about IEnumerable, ICollection, IList, and List. We will also focus on how to choose the right one. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/collections-csharp/IEnumerableVsICollectionVsIListVsList"...

Convert a File to a Byte Array in C#

Convert a File to a Byte Array in C#

In this article, we will learn about situations where we may need to convert a file into a byte array. Additionally, we will learn two ways to perform the conversion in C#. If you want to learn how to convert a byte array to a file, check out our convert byte array to...

Different Types of Comments in C# and Should We Use Them

Different Types of Comments in C# and Should We Use Them

In this article, we are going to talk about different types of comments in C#. The compiler will compile any syntactically correct code into an intermediate language, and after that, the .NET runtime will execute this IL code on the client computer. The computer will...

Resolving the Call Is Ambiguous Error While Using LINQ

Resolving the Call Is Ambiguous Error While Using LINQ

In this article, we will learn when the "call is ambiguous" error happens, why the error happens, and how to work around the issue. There are still so many legacy projects using older versions of EF Core, and in those projects, this error can cause a lot of headaches...

Create Clean Guard Clauses With GuardClauses in C#

Create Clean Guard Clauses With GuardClauses in C#

In this article, we discuss how to create guard clauses, how they differ from user input validation, and how to improve our guards by writing clean guard clauses leveraging the GuardClauses library. [sc name="github"...

File and FileInfo Class Comparation in C#

File and FileInfo Class Comparation in C#

In this article, we will look at the power of the File and FileInfo classes used for file manipulation in C#.  We'll uncover the similarities and differences between these two classes and why we would want to use one over the other.  [sc name="github"...

Determine Whether Two Date Ranges Overlap in C#

Determine Whether Two Date Ranges Overlap in C#

In this article, we will discuss how to determine whether two date ranges overlap in C#. We will explore how to achieve this result using the DateOnly and TimeOnly records and then, we're going to beautify our implementation with a custom class representing date...