Our Blogs

What's New in C# 7.0

August 27, 2016
C# is used for the custom software development purposes. C# 7.0 brings in a number of new features and brings a focus on data consumption, code simplification and performance. The main attraction of C# is the addition of tuples, which make it easy to have multiple results, and pattern matching which simplifies code that is conditional on the shape of data.

Out variables

C# 7.0 ships with support for out variables, which provides the ability to declare a variable right at the point where it is 
passed as an out argument.

public void PrintCoordinates(Point p)
    p.GetCoordinates(out int x, out int y);
    WriteLine($"({x}, {y})");

Pattern matching

C# 7.0 provides support for pattern matching. It introduces the notion of patterns, which are syntactic elements that can test that a value has a certain "shape", and extract information from the value when it does.

Is-expressions with patterns

The pattern variables are similar to the out variables described earlier. They can be declared in the middle of an expression 
and can be used within the nearest surrounding scope. Moreover, pattern variables are mutable.

Switch statements with patterns

By introducing the new Switch statements with patterns, the order of case clauses matters. Moreover, the compiler will 
enable you to flag obivious cases that can never be reached. Here, the default clause is always evaluated first. Furthermore, 
the null clause at the end is not unreachable.


C# 7.0 brings in tuple types and literals. The method now effectively returns the strings, which are wrapped up as elements 
in a tuple value. The caller of the method receives a tuple and will be able to access the elements individually.


C# introduces a deconstructing declaration. It is a syntax for splitting a tuple into several parts. Moreover, the split parts are 
assigned to fresh variables individually.

Some of the other core features of C# 7.0 are local functions, literal improvements, generalized async return types, throw  expressions including ref returns and locals. C# 7.0 will be an effective programming language for your custom software development.