C# 7.0 Features



C#7.0 - supported from Visual Studio 2017.

This version has some evolutionary and cool stuff in the vein of C# 6.0,but without the compiler as a service. Here are some of the new features :
Expanded expression bodied members
Features Description Examples
Out variables Before The only way to initialize an Auto Property is to implement an explicit constructor and set property values inside it.
Tuples and deconstruction In C# 6, primary constructor gives us a shortcut syntax for defining constructor with parameters. Only one primary constructor per class is allowed.
Pattern matching dictionary initializer like an array using square brackets.
  
public class DictionaryInitializerInCSharp6
{
    public Dictionary _users { get; } = new Dictionary()
    {
        ["users"]  = "Venkat Baggu Blog",
        ["Features"] =  "Whats new in C# 6" 
    };
}

Local functions await keyword is not available inside the catch and finally blocks. In C# 6, we can finally use the await keyword inside catch and finally blocks.
Expanded expression bodied members
Ref locals and returns

Comments