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

Configure Visual Studio to Use File-Scoped Namespaces on New Classes

Filed-scoped namespaces were a new feature added to C# 10. File-scoped namespaces simplify the organization of code by allowing you to declare the namespace at the file level rather than wrapping each type in its own namespace block. This can lead to more readable and concise code with one less layer of curly braces in … Continue reading Configure Visual Studio to Use File-Scoped Namespaces on New Classes

GitHub Enterprise included with Visual Studio Subscription

I learned today that the GitHub Enterprise license is included with your Visual Studio Subscription (previously MSDN subscription). This means that you can use the Enterprise features of GitHub when you tie your VS Subscription with it. Great news for people with that subscription, so you don't have to pay for both. Here is a … Continue reading GitHub Enterprise included with Visual Studio Subscription

Getting Started with Minimal WebAPI: Beginner’s Guide

Minimal WebAPIs offer a lightweight and streamlined approach to building web APIs in ASP.NET Core. In this beginner's guide, we will explore the fundamental concepts of Minimal WebAPI development using C#. We'll cover the basics of creating endpoints, handling requests, and returning responses. Prerequisites To follow along with this guide, you should have a basic … Continue reading Getting Started with Minimal WebAPI: Beginner’s Guide

Level up string manipulation with String Interpolation in C#

String manipulation is a fundamental aspect of software development, allowing us to create dynamic and expressive outputs. In C#, one powerful tool that enhances the readability and simplicity of string manipulation is string interpolation. Let's explore the benefits and usage of string interpolation in C#, and how it can improve your coding experience. What is … Continue reading Level up string manipulation with String Interpolation in C#