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
Category: .NET
Introduction to Immutability with Records in C#
With C# 9.0, Microsoft introduced the record keyword, a powerful new addition that makes it easier to work with immutable data. Records are designed to simplify the creation of classes that are primarily intended to store data, and they offer a more concise and expressive way to model data compared to traditional classes. If you've … Continue reading Introduction to Immutability with Records in C#
Basic C# Immutability with Tuples
In software development, one of the common challenges is returning multiple values from a method. Traditionally, we’ve handled this by using techniques like out parameters, creating custom classes or structs, or working with arrays and lists. However, with the introduction of tuples in C#, particularly since C# 7.0, there's a more elegant and straightforward way … Continue reading Basic C# Immutability with Tuples
Why Should I Care about Mutable vs. Immutable Types
In C#, classes and objects can be categorized as mutable or immutable based on whether their state can be changed after they are created. Understanding the distinction between mutable and immutable types is crucial for designing robust, maintainable, and performant applications. Mutable Classes Mutable classes are those whose state or data can be modified after … Continue reading Why Should I Care about Mutable vs. Immutable Types
“NuGet Why” Command: Understanding Dependency Graphs in .NET Projects
Introduction Managing dependencies in .NET projects can sometimes be a challenging task, especially when trying to understand how various packages interrelate in your solution. Enter the dotnet nuget why command—a powerful tool introduced in the .NET 8.0.4xx SDK and later versions. This command allows you to visualize and analyze the dependency graph for a specific … Continue reading “NuGet Why” Command: Understanding Dependency Graphs in .NET Projects
Why Should I Care About Functional Programming in C#?
Functional programming (FP) is a programming paradigm that emphasizes immutability, first-class functions, and expressions over statements. While C# is primarily an object-oriented language, it has incorporated many functional programming features over time, particularly since C# 3.0 and with further enhancements in later versions. Here's why you should care about functional programming when working with C#: … Continue reading Why Should I Care About Functional Programming in C#?
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
Global Using Directives
In C# 10, a new feature was introduced that allows you to specify global using directives. This feature lets you define using directives that apply to all the files in your project, reducing the need for repetitive using statements in each file. This can be particularly useful for commonly used namespaces. How to Specify Global … Continue reading Global Using Directives
Integration Tests for Minimal API with SQL Server TestContainers
Integration tests are important for ensuring that your application components work together as expected. When it comes to testing APIs, having a reliable and isolated database environment can significantly improve the accuracy of your tests. By using test containers over other concepts like in memory database, you will actually test the behavior end-to-end, including the … Continue reading Integration Tests for Minimal API with SQL Server TestContainers