Automatic Registration of Minimal API Endpoints in .NET
In this article, we will explore how we can improve our Minimal API endpoints in .NET with automatic registration. Let's dive...
Comparing Performance of the switch and if-else Statements in C#
In this article, we delve into the performance nuances of switch and if-else statements in C#, two pivotal control flow mechanisms. Through a comparative analysis, we'll explore how each statement impacts application performance under various conditions, supported by...
How to Use StringPool to Reduce String Allocations in C#
In software development, effective memory management plays a pivotal role, acting as a secret sauce to enhance our application's performance. When working with C# code, managing strings, a common task, significantly impacts our program's memory usage. Because .NET...
Fastest Way to Generate a Random Boolean in C#
Generating random boolean values is a common challenge in programming tasks, especially when randomness is required for gaming or testing data. With that said, let's explore some methods to generate boolean values as quickly as possible. [sc name="github"...
How to Send a JSON Object Using HttpClient in .NET
In modern web development, sending JSON objects over HTTP has become a common practice for exchanging data between clients and servers. In this article, we will explore how to send a JSON object using HttpClient. [sc name="github"...
Exception Handling in C#
In this article, we will dive into exception handling, explore user-defined exception creation, and demonstrate implementing a global exception handler in C#. [sc name="github"...
Fastest Way to Get the First N Characters of a String in C#
In this article, we will perform benchmark tests to determine the fastest way to get the first N characters of a string in C#. We will start by creating an input string. Then, we will define and explain different methods that we can utilize to accomplish this task. At...
Get the Date of the First Day In a Week Given the Week Number and a Year In C#
Have you ever asked yourself how to calculate the date of the first day in a week, given the week number and a year in C#? The Gregorian Calendar has fifty-two full weeks and an extra day in a normal year, equivalent to 52.143. However, it also includes leap years...
Difference Between Abstraction and Encapsulation in C#
Let's explore the differences between abstraction and encapsulation in C#. Abstraction and encapsulation constitute fundamental concepts in object-oriented programming (OOP) and coexist in C#. Each of them fulfills key roles in the design and implementation of classes...
Architecture Tests in .NET with NetArchTest.Rules
In this article, we'll explore how to use the NetArchTest.Rules library to write architecture tests for our .NET applications. Let's...
How to Create an Outer Join in LINQ – (Left and Right)
In this article, we'll discuss how to create an outer join in LINQ. Most used are left and right outer join, but we'll also talk about less common ones. It's hard to find an application that doesn't rely on data. We often use just a single data source. But sometimes...
Read a Text File Without Specifying the Full Path in C#
In .NET applications, reading text files is essential for tasks like loading configurations, processing data, and parsing logs. In this article, we look at the file's relative and absolute paths and set up a new project to read a text file using its relative path. [sc...
Introduction to Brighter in .NET
Brighter is a feature-rich .NET library for dispatching and processing commands that make it easy to implement in-process and out-of-process processing; moreover, it makes it easy to implement CQRS architecture. In this article, we will learn how to use Brighter in...
How to Get the Quarter of a Given Date in C#
Manipulating DateTime values is one of the most common operations in any application. Have we ever asked ourselves how to extract the quarter of a given date value in C#? In this article, we are going to understand how we can derive the quarter and financial quarter...
How to Fix CORS Error With AnyOrigin and AllowCredentials
In this article, we will learn how to fix the CORS protocol error with AnyOrigin and AllowCredentials in ASP.NET Core (The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time). We assume you know the basics of CORS and how...
How to Add Unique Constraints to a Property in EF Core Code-First
In this article, we'll see how we can apply unique constraints to a property in EF (Entity Framework) Core using the code-first approach. ...
Difference Between Build and Publish in Visual Studio
Has anyone ever wondered about the difference between the build and publish functions in software development? As we know, both the build and publish are important steps in software development, especially when using Visual Studio for .NET applications. Let’s check...
Fastest Method to Check if a Date Is Less Than or Equal to Today’s Date in C#
In our applications, there may be a need to check if an input date string is less than or equal to today's date. This information is crucial for various scenarios, including scheduling events, validating user-entered dates, and updating entities in our database. In...
How to Inject a DbContext Instance Into an IHostedService
In this article, we'll take a look at how to inject a DbContext instance into an IHostedService. We'll also point out some important concepts we should be aware of. [sc name="github"...
Single and Split Queries in Entity Framework Core
Entity Framework Core (EF Core) offers developers two powerful querying strategies: Single and Split Queries. In this article, we'll delve into the pros and cons of each, helping us make informed decisions for efficient data retrieval. The sample in our repository...
Clean Architecture in .NET
In this article, we are going to discuss Clean Architecture in .NET. So let's get going. [sc name="videolink" videotitle="Clean Architecture with...




