C# version wise new features

Sudip Bhatt 2,271 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

C#
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.
10,457 questions
0 comments No comments
{count} votes

Accepted answer
  1. Karen Payne MVP 35,286 Reputation points
    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


0 additional answers

Sort by: Most helpful