Latest Posts On Code Maze

Central Package Management for .NET Projects

Central Package Management for .NET Projects

Nowadays, every non-trivial software project depends on a number of external dependencies. Good software design is all about modularity, and that's one of the reasons behind NuGet's success in the .NET world. NuGet is the famous, well-integrated package manager for...

Implementing API Gateway with Ocelot in ASP.NET Core

Implementing API Gateway with Ocelot in ASP.NET Core

In this article, we are going to learn how to implement an API Gateway using Ocelot. Ocelot is an open-source API Gateway, designed for microservices architecture. [sc name="patreon-source-code"...

Using the when Keyword in C# While Handling Exceptions

Using the when Keyword in C# While Handling Exceptions

In this article, we are going to learn why and how to use the when keyword within try-catch blocks while handling exceptions in C#. We cannot avoid the occurrence of exceptions in the life cycle of an application. An exception is a problem that appears unexpectedly...

How to Read Data From a CSV File in C#

How to Read Data From a CSV File in C#

Reading from a CSV file in C# is a common operation. In this article, we are going to show how to easily read data from a CSV file in C# using the CSVHelper NuGet package. [sc name="patreon-source-code"...

Check if a Number is a Power of 2 in C#

Check if a Number is a Power of 2 in C#

In this article, we are going to learn the most efficient and popular solutions to a very common problem - checking if a number is a power of 2. While it seems an easy task, we will see that some of these solutions are faulty in presence of corner cases. [sc...

Copy the Entire Contents of a Directory in C#

Copy the Entire Contents of a Directory in C#

In .NET, there is no built-in way to copy the entire contents of a directory including subfolders and their content. In this article, we will explore a clean, platform-agnostic solution for this operation. Additionally, we will see how we can implement this in the...

How to Return HTML From ASP.NET Core Web API

How to Return HTML From ASP.NET Core Web API

A typical web API returns JSON or XML responses. However, rare cases exist where we need to return responses in other formats. In this article, we are going to learn how to return HTML from ASP.NET Core Web API. We will also state some use cases for this type of API....

Sorting and Filtering With LINQ

Sorting and Filtering With LINQ

In this article, we are going to learn about Sorting and Filtering with LINQ. Language-Integrated Query, or LINQ for short, provides a robust set of language extensions that we can use to shape query results according to our current needs. LINQ not only allows for a...

Set C# Language Version for All the Projects in a Solution

Set C# Language Version for All the Projects in a Solution

C# language is actively developed. This means that from time to time a new version of the language is released. New versions give us access to recently added features and syntactic sugar. The default choice of the version depends on the target framework of the...

Google Charts With Angular and ASP.NET Core Web API

Google Charts With Angular and ASP.NET Core Web API

In this article, we are going to look at using charts with Angular and ASP.NET Core Web API to visualize the relationship between data. We'll use Google Charts to create the visualization. It is a Javascript-based library used for data charting and visualization. We...

Priority Queue in C#

Priority Queue in C#

Priority Queue in C# is a very useful data structure that has so many real-world applications. In this article, we are going to cover the main concepts of Priority Queue in C#. We have covered the basic Queue in C#, it is recommended to check it out before continuing...

Long-Running Tasks in a Monolith ASP.NET Core Application

Long-Running Tasks in a Monolith ASP.NET Core Application

Often we come across scenarios where invoking a Web API endpoint triggers long-running tasks. In this article, we're going to explore the different ways we can implement such a long-running task in an ASP.NET Core Web API. [sc name="github"...

Introduction to Testing Blazor WebAssembly With bUnit

Introduction to Testing Blazor WebAssembly With bUnit

In this article, we are going to learn about unit testing a Blazor WebAssembly Project using the bUnit testing library. If you find some of the concepts we are testing hard to understand, we have a great Blazor WebAssembly Series that is worth checking out. [sc...

Insertion Sort in C#

Insertion Sort in C#

We have different sorting algorithms that we can use when we want to sort lists of elements. Insertion sort is one of the simplest algorithms that we can use to achieve our goal. In this article, we learn how insertion sort works, implement the algorithm in C#, and...

JSON Deserialization to a POCO Class in C#

JSON Deserialization to a POCO Class in C#

Deserialization is the process of taking a string representation of an object and creating that object in memory. JSON is an ever-increasingly popular format to serialize objects into. It has become nearly ubiquitous in API communication. In this article, we will take...

Using dotnet format Command to Format the C#/.NET Code

Using dotnet format Command to Format the C#/.NET Code

In this article, we are going to look into a global .NET tool called dotnet format, that helps with code styling in our .NET applications. We'll explore the basic usage, how the role of .editorconfig is important, and how to make the best use of the dotnet format in...

Upload Files With Drag & Drop or Paste in Blazor

Upload Files With Drag & Drop or Paste in Blazor

In this article, we are going to look at how we can upload files to a Blazor Server application using Drag & Drop, as well as Copy/Paste functionality. We will be making use of the JavaScript Interop to invoke JavaScript functions from our C# code. Therefore, we...