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:

StyleCop Analyzers Implementation in .NET

As developers, we often have different ideas for writing our code. While coding style preferences can differ, being consistent is important. In this article, we will explore the benefits of StyleCop Analyzers and how they can help us enforce a unified coding style...

Compare Byte Arrays in .NET

In .NET, byte arrays are a common data type used to represent a sequence of bytes. They often represent binary data such as images, audio files, or serialized objects. Comparing byte arrays in .NET requires a good understanding of how the .NET framework handles arrays...

How to Integrate BenchmarkDotNet With Unit Tests

In this article, we will learn how to integrate BenchmarkDotNet with Unit Tests and use some advanced APIs of the BenchmarkDotNet library when doing that. In the .NET ecosystem, BenchmarkDotNet is the go-to library for conducting performance benchmarks. Typically we...

Convert a Byte Array to a Hex String in C#

Convert.ToHexString() turns a byte array into an uppercase hex string in one line, and Convert.ToHexStringLower() does the same in lowercase. On .NET 5 and later, that is the answer. The rest of this article is about the cases where that answer does not apply, and...

Roslyn Compiler and Analyzers in .NET – Introduction

In this article, we will introduce Roslyn compiler and analyzers in .NET. Moreover, we will delve into utilizing Roslyn to compile C# code and explore various types of Roslyn analyzers. Roslyn is an open-source compiler for C# and Visual Basic. Roslyn exposes a wide...

Redis Cache in C#: How to Cache Web Application Data

To cache data in Redis from C#, we register AddStackExchangeRedisCache() in Program.cs, inject IDistributedCache, and read through the cache: ask Redis first, fall back to the database on a miss, and write the result back with an expiration. Redis is an in-memory...

Parse String to DateTime in C#: Parse, TryParse, ParseExact

C# has four methods for turning a string into a DateTime, and the names tell us what they do. Parse() and TryParse() differ only in how they fail: Parse() reads whatever the culture allows and throws on failure, and TryParse() does the same and returns false instead....

Test Data Generation With AutoFixture in .NET

In this article, we will explore how to automate test data generation, enhance productivity, improve test coverage, and reduce maintenance efforts with a single library called AutoFixture. [sc name="github"...

DateTime Calendars in C#

When working with dates, we must consider the fact that there are many different calendar systems worldwide. The default calendar used in C# DateTime operations is the Gregorian calendar, since it's the most popular system. However, there are situations where we may...

ArrayList in C#

In this article, we are going to learn about ArrayList. It is one of the collection types in C# that allows us a flexible option to store data. ...

Value Objects in C#: Records, Validation and EF Core

A value object is a type we identify by its values, not by an ID. Two Money values of 100 USD are the same money, the same way two 5s are the same number. In C#, a record gets us most of the way there. It compares by value out of the box, and its positional properties...

Execute a PowerShell Script in C#

In this article, we’ll learn how to execute a PowerShell script in C# using the ProcessStartInfo class from System.Diagnostics namespace and PowerShell classes from the System.Management.Automation namespace, which is available in PowerShell.SDK. [sc name="github"...

Differences Between ExpandoObject, DynamicObject and dynamic

In C#,  the dynamic keyword, the ExpandoObject class, and the DynamicObject class, are the main approaches to working with dynamic objects. However, ExpandoObject and DynamicObject are often used interchangeably, so it can be quite difficult to distinguish them. In...

Working With Guid in C#

In the world of software development, maintaining data integrity and uniqueness is of utmost importance. One such unique identifier in C# is the Guid (Globally Unique Identifier) class. In this article, we will explore the Guid class in .NET, its features, and how we...

How to Get Class Name as String in C#

In our programming journey, there are times when we might find ourselves in a situation where we need to obtain the class name as a string. This proves beneficial for many reasons, such as logging, debugging, or other programming endeavors. In C#, there are different...

How to Add a Global Route Prefix in ASP.NET Core

In this article, we will learn how to add a global route prefix in ASP.NET Core. This enables us to effortlessly incorporate the route prefix into our application's routing mechanism, offering greater flexibility and control. [sc name="github"...

How to Read Values From Query Strings In ASP.NET Core

In this article, we are going to learn how to read values from query strings in ASP.NET Core. In web development, the capability to read and utilize values from the query string holds significant importance. It is crucial to adeptly interpret the parameters...

InProcess and OutOfProcess Hosting Models in ASP.NET Core

In this article, we will compare InProcess and OutOfProcess hosting models in ASP.NET Core and learn more about each hosting model. Hosting refers to deploying an application into the server for external access. Understanding the hosting process is essential in...