Latest Posts On Code Maze

Bouncy Castle Cryptography in C# and .NET

Bouncy Castle Cryptography in C# and .NET

Bouncy Castle is a cryptography library for .NET that ships the algorithms and formats System.Security.Cryptography does not, such as Ed25519, Blowfish, IDEA, Camellia and OpenPGP. Where the two overlap, the built-in types do the same job with fewer moving parts. So...

Embedded Resources in C# and .NET

Embedded Resources in C# and .NET

An embedded resource is a file the compiler writes into the assembly itself, so the DLL or EXE carries it instead of shipping a loose file next to it. A text file, an image or a PDF goes in unchanged and comes back out through System.Reflection, not through a file...

How to Print a 2D Array to the Console in C#

How to Print a 2D Array to the Console in C#

In this article, we will learn how to print a 2D array to the console using C#. Whether we are handling complex data structures or simply organizing information efficiently, understanding how to manipulate 2D arrays is a valuable skill. [sc name="github"...

Getting Started With EasyCaching in ASP.NET Core

Getting Started With EasyCaching in ASP.NET Core

EasyCaching is an open-source caching library that helps us manage caching more easily, and flexibly and it's an alternative to ASP.NET Core's out-of-the-box caching library. Caching is a prevalent and useful technique for improving the performance of web...

Lookup in C#

Lookup in C#

When we build our .NET applications, we commonly use dictionaries to store data as key-value pairs. However, dictionaries do not allow us to map multiple values to a single key. In this article, let's explore the Lookup class in C# and discuss how we can use it to...

Modular Monolith Architecture in C# and .NET

Modular Monolith Architecture in C# and .NET

A modular monolith is one application, deployed as one unit, whose code we split into loosely coupled modules along business lines. Let's see how it compares with traditional monoliths and microservices, and then build one in .NET with two modules. We will also...

Fastest Ways to Perform Base 10 Conversions in C#

Fastest Ways to Perform Base 10 Conversions in C#

Performing base 10 conversions is fundamental when learning basic computer science and mathematical concepts. Since we know computer systems understand binary, such conversions can help us form different number representations that we can use for various applications...

How to Compare Two Dictionaries in C#

How to Compare Two Dictionaries in C#

In this article, we will first explore several ways to compare two dictionaries in C#. Then, we will compare and rank the performance of these approaches using the BenchmarkDotNet library. When we work with Dictionary objects in C#, checking their equality is a common...

Introduction to the StronglyTypedId Package in .NET

Introduction to the StronglyTypedId Package in .NET

In this article, we'll look at the StronglyTypedId NuGet package and how it helps us enhance type safety and code readability in our .NET projects by generating strongly-typed IDs for our entities. [sc name="github"...

How to Compare Two Files in C#

How to Compare Two Files in C#

In this article, we will learn how to compare two files in C#. There are several reasons why we might want to compare two files in our code, such as integrity checks, detecting duplicate files, version control, synchronization, and more. But what are the different...

JsonSerializerOptions in ASP.NET Core: Set Global Defaults

JsonSerializerOptions in ASP.NET Core: Set Global Defaults

To set global JsonSerializerOptions defaults in ASP.NET Core, configure them once at startup: AddJsonOptions() for controllers, ConfigureHttpJsonOptions() for minimal API endpoints, or AddNewtonsoftJson() to hand serialization back to Json.NET. ASP.NET Core serializes...

How to Filter a List Based on Another List In C#

How to Filter a List Based on Another List In C#

Lists in C# are one of the most ubiquitous data structures. We perform all kinds of operations on them, such as appending, inserting, removing, sorting, and filtering. In this article, we'll focus on the latter - filtering. In particular, we'll see how to use a list...

View-Based Authorization in ASP.NET Core

View-Based Authorization in ASP.NET Core

View-based authorization is an authorization strategy that enables us to manage UI elements' visibility based on the user's identity. In this article, we'll take a look at how we can achieve view-based authorization in an ASP.NET core application. [sc name="github"...

Add a Cookie to an HttpClient Request/Response in ASP.NET Core

Add a Cookie to an HttpClient Request/Response in ASP.NET Core

What are cookies? Websites send small pieces of text, known as internet cookies, to our browsers whenever we visit them. They help us have a personalized experience on that particular website and remember it for the next time we visit it. Our goal today is how to make...