C# 7 adds a number of new features and focuses on data consumption, code simplification and performance. The biggest features have already been considered - tuples, local functions, matching with the pattern and throwing expressions. But there are other new opportunities, both large and small. They all combine to make the code more efficient and understandable, so that everyone is happy and productive.
Let's look at the rest of the features of the new version of C #. So! Let's start!
Out
Currently, in C #, using out parameters is not as flexible as we would like. Before calling a method with out parameters, you first need to declare the variables to pass to the method. Because these variables are usually not initialized (since they will be overwritten by the method), you can not use var for their declaration, so you must always specify the full type:
public void PrintCoordinates(Point p) { int x, y; // have to "predeclare" p.GetCoordinates(out x, out y); WriteLine($"({x}, {y})"); }
Literals Improvements
var d = 123_456; var x = 0xAB_CD_EF;
You can put this _ symbol anywhere between the numbers the right number of times to improve readability. It does not affect the value. This separator can be used with the types byte, int, long, decimal, float and double.