Understanding await vs. ContinueWith in C# Async Programming

When it comes to asynchronous programming in C#, developers have powerful tools to make applications more responsive and efficient. By allowing long-running operations to execute in the background, we can keep the UI thread free for other tasks, resulting in smoother user experiences. Or when running those tasks on ASP.NET, the service can respond to … Continue reading Understanding await vs. ContinueWith in C# Async Programming

How to Make Internal Types Visible to Other Projects Using .csproj File

In many software development scenarios, especially when working with unit tests, you might encounter situations where you need to test internal types and methods within your code. However, internal members are, by default, inaccessible to other projects. The traditional approach to solving this problem in .NET is to make these internal types visible to specific … Continue reading How to Make Internal Types Visible to Other Projects Using .csproj File

Understanding C# Keywords

In C#, keywords play a crucial role in defining how your code behaves. They help in establishing various programming constructs like classes, methods, variables, and even asynchronous behavior in a structured and precise way. This article will explore some essential C# keywords, providing clarity on their purpose and usage. 1. sealed: Preventing Inheritance The sealed … Continue reading Understanding C# Keywords

UUID v7: Enhancing Sortable Unique Identifiers for Developers

.NET 9 brings an exciting new feature for developers: UUID v7. This new version of UUID integrates a timestamp into the traditionally random UUID structure, offering significant advantages for databases and other systems requiring sortable unique identifiers. It also still produces IDs that follow the GUID format, so they are compatible with other unique IDs … Continue reading UUID v7: Enhancing Sortable Unique Identifiers for Developers

Endpoint Explorer in Visual Studio

(Version: Visual Studio 17.6+) HTTP files are a popular feature in VSCode and were brought into Visual Studio too. Recently, I learned about another cool endpoints feature in Visual Studio called the Endpoints Explorer. This tool window lists all of the endpoints of your Web API project. You can find the Endpoints Explorer by going … Continue reading Endpoint Explorer in Visual Studio

Using GenericHost in a C# Console Application

Introduction Building useful console applications often requires structured logging, configuration management, and dependency injection. The .NET Generic Host framework provides a powerful foundation to enable these features. Let's explore how to use GenericHost in a C# console application, with a specific focus on creating a simple command-line parser. This parser will interpret and reprint command … Continue reading Using GenericHost in a C# Console Application

Creating a Fluent API in C#

Introduction Fluent API is a design pattern that provides more readable and intuitive code by chaining method calls together. This type of API is commonly used in implementing the Builder design pattern. This style enhances code readability, reduces boilerplate, and makes APIs easier to use. Fluent APIs are commonly seen in libraries like LINQ and … Continue reading Creating a Fluent API in C#

Parameter Validation Using ArgumentExceptions

In the latest .NET versions, argument validation has been streamlined with new helper extension methods that make it even easier and more expressive to throw argument exceptions. Some of these methods were first introduced in .NET 6 but have been enhanced with subsequent releases. Here are some of the latest ways to handle argument validation … Continue reading Parameter Validation Using ArgumentExceptions