Try out C# 10 new features using Visual Studio 2022

Download our ASP.NET Core 6 Web API example application we try out five new features of C# 10.

C# 10 new features

Using Visual Studio 2022 preview, you can see how the following features work in C Sharp 10:

File-scoped namespace

Declaring a namespace at the top of a file without having to wrap curly braces around it.

Record structs

C# 10 adds record structs, which was added for classes in C# 9. This has many benefits, including creating an immutable struct instance.

Constant interpolated strings

With C# 10, you can now have constant interpolated strings, as long as any objects are constant as well.

Extended property patterns

Doing a nested property condition is a lot cleaner, as you can now reference the nested property with a dot, rather than with curly braces.

Global using directive

You can now store common namespaces in a global file, meaning they are referenced for each file in your app.

Software

This is the software that will need to be installed onto your machine.

  • Visual Studio 2022 Preview 3 or above. It will work with the free community version.
  • .NET 6.0 SDK Preview 7 or above. Visual Studio 2022 should already have the .NET SDK installed.

Get the application working

These are the steps to get the application working.

  • Fill out the source code form. We will send you an email where you can download the source code.

You are now ready to go.

Open the project in Visual Studio

Open up RoundTheCode.CSharp10.sln in Visual Studio 2022.

Start the project in Visual Studio.

Hit https://localhost:6001, and you can test out the new C# 10 features.

More information

Watch our video where we go ahead and implement these five new features in a ASP.NET Core 6 Web API.

In addition, you can read about C# 10 new features and examples that are not in C# 9.

Join our Discord server

  • Can't get your ASP.NET Core application to work? Ask for help here!
  • Discussions with other ASP.NET Core developers.
  • General chat with the community.
Join Discord