Latest Posts On Code Maze

Multipart Form-Data in HttpClient with ASP.NET Core

Multipart Form-Data in HttpClient with ASP.NET Core

In this article, we will learn what multipart requests are and how we can use them. Also, we will review examples of how to send data to remote servers using multipart form-data with HttpClient in ASP.NET Core. [sc name="github"...

How to Get Formatted JSON in .Net Using C#

How to Get Formatted JSON in .Net Using C#

This article will examine how we can get a formatted JSON representation of our C# objects using two popular libraries - Json.NET and System.Text.Json. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/json-csharp/HowToGetFormattedJson"...

How to Mock EF Core DbContext

How to Mock EF Core DbContext

While unit-testing EF Core applications, sometimes, we may want to mock EF Core DbContext. In this article, we'll talk about a few ways of doing that. ...

How to Convert JSON to DataTable in C#

How to Convert JSON to DataTable in C#

In this article, we are going to discuss various methods that we can use to convert JSON to DataTable in C#. A DataTable is a representation of a database table that we can use to store data as a collection of rows and columns in a grid format. All the methods that we...

.NET Dependency Injection With Constructor Parameters

.NET Dependency Injection With Constructor Parameters

Introduction In this article, we'll look at ways to use dependency injection with constructor parameters in .NET Core. Dependency injection (DI) with constructor parameters is a way for us to pass the things our class needs (depends on) when we create a new instance...

Asynchronous Programming Patterns in .NET

Asynchronous Programming Patterns in .NET

In this article, we are going to learn about the various patterns to implement asynchronous programming in .NET. .NET has had in-built support for asynchronous programming since the release of .NET Framework 1.1. It has been through various improvements over the...

How to Clone a List in C#?

How to Clone a List in C#?

In this article, we will look at all the different ways we can clone a List in C# to another and what we should pay attention to when doing so. In...

Refactoring Bloated Code in C#

Refactoring Bloated Code in C#

In this article, we will learn what anti-patterns belong to the group of code smells called bloaters and different techniques for refactoring bloated code in C#. [sc name="github"...

Introduction to Behavior Driven Development (BDD) in C#

Introduction to Behavior Driven Development (BDD) in C#

Behavior Driven Development, or short, BDD is a software development methodology that relies on examples to define the behavior of a system. In this article, we're going to learn the bases of BDD, see what tools are available, and see BDD in action through simple...

How to Execute CLI Applications From C#

How to Execute CLI Applications From C#

In this article, we will learn how to execute CLI applications in C# using a built-in class called Process and using open-source libraries. We will cover how we can execute CLI, how we can check if the CLI execution was successful, and how we can react to the...

Method Overriding in C#

Method Overriding in C#

Method overriding in C# is a form of implementing polymorphism. We also call it "run-time" polymorphism. In this article, we are going to learn more about method overriding, how to implement it, and how it differs from method overloading. [sc name="github"...

How to Implement Checkbox List in ASP.NET Core

How to Implement Checkbox List in ASP.NET Core

A Checkbox List is an important feature to encourage multiple selections of inputs in forms. We will start with a brief overview of the existing checkbox functionality in ASP.NET Core and later on move to the implementation of a checkbox list.  [sc name="github"...

Tracking Application Health With OpenTelemetry Metrics in .NET

Tracking Application Health With OpenTelemetry Metrics in .NET

The ability to gather metrics for our .NET applications is very important, as it allows us to gain insight into the health and performance, as well as any issues our applications may be experiencing. Metrics are one of the 3 fundamental pillars of OpenTelemetry, and...

How to Get an Enum Member as a String in C#

How to Get an Enum Member as a String in C#

In this article, we're going to learn how to get a string representation of an enum member in C#. The possibility of defining enumeration types in C# - most widely known by the keyword enum - is a very useful feature. We can use them to assign named constants that...

Check If a String Array Contains a Value and Get Index

Check If a String Array Contains a Value and Get Index

In this article, we are going to see the different ways we can check for a specific value in a string array and return the index of that value. We will focus mainly on linear search methods. We cannot use binary search methods since we do not know if the array is...

ConcurrentDictionary in C# – Detailed Guide

ConcurrentDictionary in C# – Detailed Guide

We've already written about a regular Dictionary in C#. We've also explored the basics of ConcurrentDictionary as one of many Concurrent Collections in C#. In this article, we will go into more detail and explore the use cases in which ConcurrentDictionary can be...