Latest Posts On Code Maze

How to Remove All Whitespace Characters From a String in C#?

How to Remove All Whitespace Characters From a String in C#?

In this article, we're going to look at removing all whitespace characters from a string in C#. Strings often have leading or trailing whitespace that we would like to remove, or we may even want to remove all whitespace in between. Let's take a look at several ways...

Null-Conditional Operators in C#

Null-Conditional Operators in C#

In this article, we will discuss a feature of C# known as null-conditional operators and how it can help prevent the occurrence of null-reference exceptions, which are commonly encountered by developers. MAUI is a new technology and thus it's really fun to play around and develop with it. But what if...

How to Unit Test ILogger in ASP.NET Core

How to Unit Test ILogger in ASP.NET Core

We commonly write unit tests to test the business logic of our application. But what about the times we also want to make sure our logging works as expected? In this article, we will cover both cases and learn how to unit test ILogger in ASP.NET Core applications. ...

Vendor-Agnostic Telemetry Using OpenTelemetry Collector in .NET

Vendor-Agnostic Telemetry Using OpenTelemetry Collector in .NET

When building applications, we try to avoid being tightly coupled to any given third-party service/library, making it harder to switch this implementation with another in the future should the need arise. When working with OpenTelemetry in our applications, we can use...

How to Delete Elements from an Array in C#

How to Delete Elements from an Array in C#

In this article, we will explore several different ways to delete elements from an array in C# based on their value and compare their performance to help you choose the best option for your specific use case. An honest and insightful review of what Blazor brings us in .NET 8 by Damien...

The AddEndpointsApiExplorer Method in ASP.NET Core

The AddEndpointsApiExplorer Method in ASP.NET Core

In this article, we are going to learn about the AddEndpointsApiExplorer method in ASP.NET Core. We will learn why we need it and how we use it in our applications. For this article, we will use an ASP.NET Core Web API application with Swagger support. If you feel the...

Get Current User With Claims in ASP.NET Core

Get Current User With Claims in ASP.NET Core

In this article, we are going to see different ways to get the currently authenticated user using claims in ASP.NET Core. The code for this article is based on the respective code from the article on Authentication with ASP.NET Core Web API.  Async/Await and asynchronous programming are part of our lives for a...

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