Share via

C# version wise new features

Sudip Bhatt 2,281 Reputation points
2021-01-05T18:12:08.613+00:00

Sorry to ask you Microsoft has any pages where they mention c# version wise all new feature till latest version 9?

Thanks

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

Answer accepted by question author

Karen Payne MVP 35,606 Reputation points Volunteer Moderator
2021-01-05T19:56:25.927+00:00

Hello @Sudip Bhatt

Start here, What's new in C# 9.

For setting up a project in VS2019, double click on the project file in Solution Explorer and alter as shown below

<Project Sdk="Microsoft.NET.Sdk">  
  
 <PropertyGroup>  
 <OutputType>Exe</OutputType>  
 <TargetFramework>net5.0</TargetFramework>  
 <LangVersion>9.0</LangVersion>  
 <RootNamespace>YOUR NAMESPACE</RootNamespace>  
 </PropertyGroup>  
  
</Project>  

Note that when exploring C# 9 many sites still show proposals e.g. using ! for not null for method parameters which in this case didn't make it in but instead rather than ! [NotNull] attribute was introduced.

private string NoNullExample([NotNull] string value) => value.ToLower();  

Records seem to attract a good deal of attention so check this out and on the left other C# 9 docs
https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/exploration/records

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.