C# 10: What's new? New features and updates in C# (use in .NET 6)

Опубликовано: 21 Октябрь 2024
на канале: Round The Code
9,942
298

What's new in C# 10? We try out five new features in C#.

These are amongst a number of updates that were applied to C# when .NET 6 is released.

The features we cover are:

● File-scoped namespace
Being able to use a namespace in a file, without having to wrap curly braces around it.

● Record structs
C# 9 introduced the record class feature. C# 10 goes further and you can now apply record structs. Handy if you want to make a struct immutable.

● Constant interpolated strings
Interpolated strings allow you to insert an object into a string without coming out of it. Now you can set an interpolated string as a constant.

● Extended property patterns
Handy if you are doing a condition on a nested property. You can now use a dot to get the nested property, rather than using curly braces.

● Global using directive
Being able to import namespaces that are commonly used into a single file, so they don't have to be imported in each individual file.

💻 Download the code sample for this demo 💻
https://www.roundthecode.com/dotnet-c...

📖 Learn .NET and C# with our online courses 📖
https://www.roundthecode.com/dotnet-c...

► More information: https://www.roundthecode.com/dotnet-b...

► .NET 6, C# 10 and Visual Studio 2022 playlist:    • .NET 6, C# 10 and Visual Studio 2022  

► Chapters
0:00 C# 10 development in full swing
0:44 File-scoped namespace
1:37 Record structs
4:38 Constant interpolated strings
6:52 Extended property patterns
9:39 Global using directive
10:43 How to use C# 10
11:15 C# 10 review

#csharp #dotnet #visualstudio