Methods Returning Multiple Values

There are cases in practice when we need a method to return more than one element as a result. For this to be possible ValueTuple has been integrated in Visual Studio and C# (onwards from C# 7), and also a literal of type ValueTuple. The type ValueTuple represents two values, which allow the temporary containing of multiple values. The values are contained in variables (fields - we will earn about them later) of the corresponding types. Although the type Tuple existed before C# 7, it didn't have good support in the older versions and it's ineffective. That's why in previous versions of C# the elements in one Tuple were shown as Item1, Item2 etc. and the names of their variables (the variables in which they are contained) could not be changed. In C# 7 the type (ValueTuple) is maintained, which allows giving meaningful names to the elements in a ValueTuple.

results matching ""

    No results matching ""