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#
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#
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 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#
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
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 Check if an Object Is a Number in C#
In this article, we will explore different methods to check if an object is a number. C# is a strongly typed programming language, which ensures...
Creating Conditional Required Attributes for Validation in .NET Web API
Whether seasoned or just getting started in the .NET world, we've all encountered situations where we need to conditionally validate some attributes of data based on specific conditions. In this article, we're going to learn about creating conditional required...
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...
How to Overwrite DateTime.Now During Testing in .NET
In this article, we'll look closer at how we can overwrite the DateTime.Now property when testing applications in .NET. Let's dive in!...
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
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...
How to Get the Number of Files in a Folder With C#
In this article, we are going to see how to get the number of files in a folder. C# provides several methods to determine file counts within a folder, each tailored for specific use cases. [sc name="github"...
The Difference Between RESTful APIs and Web APIs Using ASP.NET Core
In this article, we will discuss the difference between RESTful APIs and Web APIs using the ASP.NET Core framework. We'll begin by explaining what exactly an API is. Then, we'll explain the meaning of REST and RESTful. After that, we will delve into Web APIs. Finally,...