Value tuples
A value tuple is a data structure that has a specific number and sequence of values. .NET provides the following built-in value tuple types:
- The ValueTuple<T1> structure represents a value tuple that has one element.
- The ValueTuple<T1,T2> structure represents a value tuple that has two elements.-
- The ValueTuple<T1,T2,T3> structure represents a value tuple that has three elements.
- The ValueTuple<T1,T2,T3,T4> structure represents a value tuple that has four elements.
- The ValueTuple<T1,T2,T3,T4,T5> structure represents a value tuple that has five elements.
- The ValueTuple<T1,T2,T3,T4,T5,T6> structure represents a value tuple that has six elements.
- The ValueTuple<T1,T2,T3,T4,T5,T6,T7> structure represents a value tuple that has seven elements.
- The ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> structure represents a value tuple that has eight or more elements.
The value tuple types differ from the tuple types (such as Tuple<T1,T2>) as follows:
- They are structures (value types) rather than classes (reference types).
- Members such as Item1 and Item2 are fields rather than properties.
- Their fields are mutable rather than read-only.
The value tuple types provide the runtime implementation that supports tuples in C# and struct tuples in F#. In addition to creating a ValueTuple<T1,T2> instance by using language syntax, you can call the Create factory method.
See also
Tee yhteistyötä kanssamme GitHubissa
Tämän sisällön lähde on GitHubissa, jossa voit myös luoda ja tarkastella ongelmia ja pull-pyyntöjä. Katso lisätietoja osallistujan oppaasta.