How to get Second Element of the ValueTuple in C#?
ValueTuple is a structure introduced in C# 7.0 which represents the value type Tuple. It allows you to store a data set which contains multiple values that may or may not be related to each other. Item2 Property is used to get the second unnamed element of the given value tuple. It is applicable on every value tuple like 2-ValueTuple, 3-ValueTuple, and so on.
public T2 Item2;
Here, T2 is the field value of a ValueTuple<> structure. This ValueTuple<> can be 2-ValueTuple, or 3-ValueTuple, or 4-ValueTuple, or 5-ValueTuple, or 6-ValueTuple, or 7-ValueTuple, or 8-ValueTuple.
Example: In the below code, you can see that we are accessing the second element of each value tuple.
C# Topics: String List Dictionary Data Types Class Constructors Method Hiding