C# 12 updates - Introduction
This image is generated using Dall-EPrompt: Generate an image of computer screen where some programming language is being displayed on the screen in a minimalistic flat style
A couple of weeks ago Microsoft has launched C# 12 which packed a lot of new features (Microsoft, 2023).
If that’s not a reason to start diving into the new C#-features, I don’t know what is. The best part about this update, at least to me, is that there are some concepts of which I’m not quite sure what they actually are, or even why I would want to use them in the first place.
That’s why I’m starting a small series on the C# 12 features that I want to deep dive into, learning about the concepts, figuring out how to implement it and figure out what the use-cases are.
Setup
For my own sanity and redelivery purposes, I’ll be going over the environment I’ve setup for the dive into C# 12. I’ll be using .NET 8, because it’s the latest LTS release.
If you already have a working environment, feel free to ignore this section completely.
Install .NET 8
Before I can dive into .NET, I have installed it using Homebrew on macOS.
1
$ brew install dotnet@8
*Note the @8
is not required since the latest version of the formula is already 8. But for repeatability’s sake, I’ve included it.
Set up the solution
All features will be added as a project to the csharp-12-features
solution on github.com/bartkessels/dotnet-8-features.
The solution is created using the .NET cli.
1
2
3
$ mkdir csharp-12-features
$ cd csharp-12-features
$ dotnet new sln
And now the projects where each feature will live, this step assumes you’re still in the csharp-12-features
folder from creating the solution.
1
2
$ dotnet new console -n ProjectName
$ dotnet sln add ProjectName
*Note each project will be a console project because it’s pretty assumable that something is going to be printed to an output.
Categories
Related articles