ValueTuple<T1,T2,T3> ValueTuple<T1,T2,T3> ValueTuple<T1,T2,T3> ValueTuple<T1,T2,T3> Struct

Definition

Represents a value tuple with 3 components.

generic <typename T1, typename T2, typename T3>
public value class ValueTuple : IComparable, IComparable<ValueTuple<T1, T2, T3>>, IEquatable<ValueTuple<T1, T2, T3>>, System::Collections::IStructuralComparable, System::Collections::IStructuralEquatable
[System.Serializable]
public struct ValueTuple<T1,T2,T3> : IComparable, IComparable<ValueTuple<T1,T2,T3>>, IEquatable<ValueTuple<T1,T2,T3>>, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable
type ValueTuple<'T1, 'T2, 'T3> = struct
Public Structure ValueTuple(Of T1, T2, T3)
Implements IComparable, IComparable(Of ValueTuple(Of T1, T2, T3)), IEquatable(Of ValueTuple(Of T1, T2, T3)), IStructuralComparable, IStructuralEquatable

Type Parameters

T1

The type of the value tuple's first element.

T2

The type of the value tuple's second element.

T3

The type of the value tuple's third element.

Inheritance
ValueTuple<T1,T2,T3>ValueTuple<T1,T2,T3>ValueTuple<T1,T2,T3>ValueTuple<T1,T2,T3>
Attributes
Implements

Remarks

A value tuple is a data structure that has a specific number and sequence of values. The ValueTuple<T1,T2,T3> structure represents a value tuple that has three elements.

The value tuple types differ from the tuple types (such as Tuple<T1,T2,T3>) 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,T3> instance by using language syntax, you can call the Create factory method.

Serialization and value tuples

The ValueTuple<T1,T2,T3> type is not serializable in .NET Core 1.x or in the .NET Framework 4.7 and earlier versions. In addition, .NET Standard, including .NET Standard 2.0, does not mandate serialization of ValueTuple<T1,T2,T3> instances; whether or not a ValueTuple<T1,T2,T3> instance is serializable depends on the individual .NET Standard implementation. To determine whether a ValueTuple<T1,T2,T3> type is serializable on a particular .NET implementation, get a Type object that represents the ValueTuple<T1,T2,T3> type and retrieve the value of its IsSerializable property. For a list of serializable types in .NET Core and the .NET Framework, see Binary Serialization.

Constructors

ValueTuple<T1,T2,T3>(T1, T2, T3) ValueTuple<T1,T2,T3>(T1, T2, T3) ValueTuple<T1,T2,T3>(T1, T2, T3) ValueTuple<T1,T2,T3>(T1, T2, T3)

Initializes a new ValueTuple<T1,T2,T3> instance.

Fields

Item1 Item1 Item1 Item1

Gets the value of the current ValueTuple<T1,T2,T3> instance's first element.

Item2 Item2 Item2 Item2

Gets the value of the current ValueTuple<T1,T2,T3> instance's second element.

Item3 Item3 Item3 Item3

Gets the value of the current ValueTuple<T1,T2,T3> instance's third element.

Methods

CompareTo(ValueTuple<T1,T2,T3>) CompareTo(ValueTuple<T1,T2,T3>) CompareTo(ValueTuple<T1,T2,T3>) CompareTo(ValueTuple<T1,T2,T3>)

Compares the current ValueTuple<T1,T2,T3> instance to a specified ValueTuple<T1,T2,T3> instance.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Returns a value that indicates whether the current ValueTuple<T1,T2,T3> instance is equal to a specified object.

Equals(ValueTuple<T1,T2,T3>) Equals(ValueTuple<T1,T2,T3>) Equals(ValueTuple<T1,T2,T3>) Equals(ValueTuple<T1,T2,T3>)

Returns a value that indicates whether the current ValueTuple<T1,T2,T3> instance is equal to a specified ValueTuple<T1,T2,T3> instance.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Calculates the hash code for the current ValueTuple<T1,T2,T3> instance.

ToString() ToString() ToString() ToString()

Returns a string that represents the value of this ValueTuple<T1,T2,T3> instance.

Explicit Interface Implementations

IStructuralComparable.CompareTo(Object, IComparer) IStructuralComparable.CompareTo(Object, IComparer) IStructuralComparable.CompareTo(Object, IComparer) IStructuralComparable.CompareTo(Object, IComparer)

Compares the current ValueTuple<T1,T2,T3> instance to a specified object by using a specified comparer and returns an integer that indicates whether the current object is before, after, or in the same position as the specified object in the sort order.

IStructuralEquatable.Equals(Object, IEqualityComparer) IStructuralEquatable.Equals(Object, IEqualityComparer) IStructuralEquatable.Equals(Object, IEqualityComparer) IStructuralEquatable.Equals(Object, IEqualityComparer)

Returns a value that indicates whether the current ValueTuple<T1,T2,T3> instance is equal to a specified object based on a specified comparison method.

IStructuralEquatable.GetHashCode(IEqualityComparer) IStructuralEquatable.GetHashCode(IEqualityComparer) IStructuralEquatable.GetHashCode(IEqualityComparer) IStructuralEquatable.GetHashCode(IEqualityComparer)

Calculates the hash code for the current ValueTuple<T1,T2,T3> instance by using a specified computation method.

IComparable.CompareTo(Object) IComparable.CompareTo(Object) IComparable.CompareTo(Object) IComparable.CompareTo(Object)

Compares the current ValueTuple<T1,T2,T3> instance to a specified object by using a specified comparer and returns an integer that indicates whether the current object is before, after, or in the same position as the specified object in the sort order.

ITuple.Item[Int32] ITuple.Item[Int32] ITuple.Item[Int32] ITuple.Item[Int32]

Gets the value of the specified ValueTuple element.

ITuple.Length ITuple.Length ITuple.Length ITuple.Length

Gets the number of elements in the ValueTuple.

Extension Methods

ToTuple<T1,T2,T3>(ValueTuple<T1,T2,T3>) ToTuple<T1,T2,T3>(ValueTuple<T1,T2,T3>) ToTuple<T1,T2,T3>(ValueTuple<T1,T2,T3>) ToTuple<T1,T2,T3>(ValueTuple<T1,T2,T3>)

Converts an instance of the ValueTuple structure to an instance of the Tuple class.

Applies to