C# now has some new features with the release of Visual Studio 2017. Those features focused on code simplification, performance and data consumption. I prepared a simple console application to show them in one file.
out variables lets us to declare variables inline. I you don’t want to declare a variable for any of out variable you can use
Constant, Type or Var patterns can be used in if statements and you can declare new inline variables as in
Switch has biggest improvements. You can switch, not just primitive types, any type you want. Patterns can be used in case clauses which can have additional conditions with
Tuples are really great but it was a backpain to use
System.Tuple<...>. Now, we just add
System.ValueTuple reference and it comes with tuple types to return and tuple literals to declare.
If you didn’t give any name to variables, you can reach to those variables as Item1, Item2 etc.
You can now declare helper functions inside a function for example recursive functions. This helps us to tidy our code.
You can use digit seperator
_ to make the code more readable.
Ref returns and locals
Now ref modifier return more than the value itself, the reference which shows the storage location in an array.
You can see all of the new features down below;
PS: You need to install free Visual Studio 2017 Community to use those features.
Source: New Features in C# 7.0