Latest Posts On Code Maze

Using Serilog with Microsoft’s ILogger API

Using Serilog with Microsoft’s ILogger API

In this article, firstly we will explore how to integrate the Serilog logging package with Microsoft's ILogger API. We will then compare the output of both logging methods to highlight the difference. If you're new to Serilog, we recommend reading our article...

How to Get the Number of Weekdays Between Two Dates in C#

How to Get the Number of Weekdays Between Two Dates in C#

Manipulating date and time values is a common programming problem in many applications. Have you ever wondered how we can calculate the number of weekdays between two dates? Knowing how to do this can be crucial in scheduling, project management, or resource...

How to Get the Number of Lines in a Text File in C#

How to Get the Number of Lines in a Text File in C#

In C#, understanding how to count lines in a text file efficiently is a fundamental skill. This seemingly simple task is essential, especially in data manipulation, analysis, or validation scenarios. Whether we are dealing with log files, configuration files, or large...

Parallel.ForEachAsync() and Task.Run() With When.All in C#

Parallel.ForEachAsync() and Task.Run() With When.All in C#

Parallel programming is a common and broad concept in the .NET world. In this article, we compare two well-known methods we use to achieve it when running a repetitive asynchronous task. We take a look at how they behave under the hood and compare the pros and cons of...

Calculate the Difference in Months Between Two Dates in C#

Calculate the Difference in Months Between Two Dates in C#

Calculating the difference in months between two dates is a useful skill for C# developers. Having this knowledge helps us in tasks such as subscription management and tracking course durations. In this article, we learn how to use DateOnly, DateTime, and TimeSpan...

How to Call SignalR Hub from Controller in ASP.NET Core

How to Call SignalR Hub from Controller in ASP.NET Core

In this article, we will look at how to call a SignalR Hub from an ASP.NET Core controller. If you are unfamiliar with setting up SignalR in your server and/or client application, check out our article for more information. Did you know there are 8 different ways to set the URLs in ASP.NET...

How to Log a Class and Method Names Using Serilog

How to Log a Class and Method Names Using Serilog

Developers must implement an efficient logging system to maintain and troubleshoot applications effectively. One popular logging library that provides powerful logging capabilities is Serilog. In this article, we will talk about how to log class and method names using...

New Features in C# 12

New Features in C# 12

In this article, we will explore new features in C# 12. We will describe primary constructors, collection expressions, inline arrays, and other newly introduced features.  We'll need the latest Visual Studio 2022 or .NET 8 SDK to try each of these new C# 12 features,...

Using Fluxor for State Management in Blazor

Using Fluxor for State Management in Blazor

In this article, we will review the Flux pattern with its benefits, and drawbacks in general. Then we will take a look into how Fluxor implements this pattern. Finally, we will learn how to use the library using an example Blazor application. Since the .NET Core term is fading away slowly, let's remember how it...