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
Author: DarthPedro
Combining Array Items into String
It's always useful to be able to combine array items into a comma delimited string whether it's for output or just debugging the contents of an array or list. C# introduced a helper method to do just that, but I always seem to forget the method and how it works. So, I'm writing this down … Continue reading Combining Array Items into String
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#
Use VS Code to Edit WebApi Projects
You can use Visual Studio Code (VS Code) as an editor for web API projects. VS Code is a lightweight, cross-platform code editor that provides a rich set of features and extensions for working with various programming languages, including C# and .NET. To work with ASP.NET Web API projects in VS Code, you need to … Continue reading Use VS Code to Edit WebApi Projects
RESTful Web APIs Book
I've been reading this book on the basics of RESTful API. It has a good description of the basics with a concentration on building hypermedia API. While that was an important part of the original REST definition, it seems to continue to be the least used and more misunderstood. But I recommend this book for … Continue reading RESTful Web APIs Book