Latest Posts On Code Maze

Working With Zip Files in C#/.NET

Working With Zip Files in C#/.NET

In this article, let's look at some of the .NET classes we can use to read, create, and update zip files. Today compressed (zip) files are all around us....

Immutable Collections in C#

Immutable Collections in C#

Working with collections can be tricky, we all made that rookie mistake when we edited elements of a list while iterating on it. Now, we might not fall into this anymore, but there are cases where we want to ensure that our collections will remain unchanged. C# has a...

Using Trie Class for Efficient Text Pattern Searching in C#

Using Trie Class for Efficient Text Pattern Searching in C#

In this article, we will explore the Trie algorithm and how to use the Trie class in C# for efficient text pattern searching. The naive approach of searching through the text character by character can be inefficient, especially for longer patterns and larger texts....

Partial Classes In C# And How to Use Them

Partial Classes In C# And How to Use Them

In this article, we will review the concept of partial classes in C#. The main idea of partial classes in C# is that the compiler constructs a single class from separate source files. It knows to combine them into a single text file before performing the language...

Output Caching in ASP.NET Core

Output Caching in ASP.NET Core

In this article, we are going to discuss how to implement Output Caching in ASP.NET. Output Caching is a first-class feature in ASP.NET Core 7. Previously we needed to implement these features ourselves, so it's beneficial that Microsoft has now built this...

Code Maze Weekly #164

Code Maze Weekly #164

Issue #164 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Top Picks Implementing the Producer-Consumer Pattern with TPL Dataflow [markheath.net] Producer-Consumer is a specialized pattern you've...

How to Exclude Properties From JSON Serialization in C#

How to Exclude Properties From JSON Serialization in C#

In this article, we are going to learn how to exclude properties from JSON serialization using the two most prominent JSON libraries for .NET. The libraries are System.Text.Json, which has been natively available in the framework since .NET Core 3.0, and...

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"...

Code Maze Weekly #163

Code Maze Weekly #163

Issue #163 of the Code Maze weekly. Check out what's new this week and enjoy the read. We've added one more section to the weekly newsletter, the "Youtube Shorts". Let us know if you like this addition and if it's interesting/helpful to you. [sc name="writeforus"...

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...