Code Maze Author

Code Maze

This is the standard author on the site. Most articles are published by individual authors, with their profiles, but when several authors have contributed, we publish collectively as a part of this profile.
Also find me here:



MY ARTICLES:

How to Round Down a Number to a Nearest Integer in C#

In this article, we will explore C# possibilities when we want to round down a number to the nearest integer. We will do that by testing several methods, which would probably first cross the minds of developers when solving this task. [sc name="github"...

How to Do an Inner Join in LINQ?

This article guides us on how to do an inner join in LINQ. We are going to discover how to seamlessly extract linked data and carry out additional LINQ tasks in conjunction with the join. Additionally, we also explore how to perform multi-level joins, that are...

How to Declare an Empty Array in C#

In this article, we are going to look at the numerous ways to declare an empty array in C#. Arrays are used to store multiple variables of the same type. Sometimes our solution design may require the use of an empty array. For example, as an initial value for a...

How to Write Logs From Startup.cs/Program.cs in .NET

Why should we write logs from the startup of an application? Usually, we write logs from various application events and user interactions. These are to record what activities the user performs, what data the app deals with, etc. When something goes wrong with our...

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#

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. [sc name="github"...

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

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. [sc name="github"...

How to Create a Custom Authorize Attribute in ASP.NET Core

Authorization is a security mechanism that determines a user's access level to a resource. We often need to implement custom authorization logic per the rules set by the organization or a project. In this article, we will learn how to implement a custom authorization...

Deep Copy of an Object in C#

In C#, when we create a new object that is a copy of an existing object, we can either create a shallow copy or a deep copy. Creating a deep copy of an object is often necessary when we need to modify the copy without affecting the original object, or when we need to...

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

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.ย  [sc name="github"...

DataTable Class in C#

In this article, we are going to cover the DataTable class in C#. DataTable is a data structure that is a member of the System.Data...

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#

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

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

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

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