C# 7 doesn't have any major updates, It has bunch useful improvements. I am going to cover two of these improvements in this article. First one I am going to focus on here is the out variables.
Out Variables
In the previous versions of C#, we had to declare the out variable before we use it.
In C# 7, we can do the same thing in one line of code. It's easier to read and we don't need to add an initial value.


The out variable we created in if statements, is available in the outer scope. Here is another example.

You can use implicitly typed local variable so you can use var when you are creating out variables.
The out variable we created in if statements, is available in the outer scope. Here is another example.
Tuples
Tuple class has been with us since Visual Studio 2010. If you have never used Tuples before, Let me try to explain them little bit here.
A tuple is a data structure that has specific number and sequence of elements. It allows you to combine multiple values in different types into a single object. Best part of it is, you don't need to create a custom class for it. One of the biggest differences between tuples and class was, Tuples did not have any custom property names until C#7.
A tuple is a data structure that has specific number and sequence of elements. It allows you to combine multiple values in different types into a single object. Best part of it is, you don't need to create a custom class for it. One of the biggest differences between tuples and class was, Tuples did not have any custom property names until C#7.
Following example creates a Tuple object and its members names will be Item1, Item2 and Item3
In C# 7, we can give them custom names, rather than calling them Items. We can do this in couple of ways. C#7 allows us to specify names for the items on both side of the assignment.
OR

Great succinct information. I learned two useful things in less time than it takes to read this comment. Thanks!
ReplyDelete