ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 结构

定义

表示 n 值元组,其中 n 为 8 更大值。Represents an n-value tuple, where n is 8 or greater.

generic <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename TRest>
 where TRest : value classpublic value class ValueTuple : IComparable, IComparable<ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>>, IEquatable<ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>>, System::Collections::IStructuralComparable, System::Collections::IStructuralEquatable, System::Runtime::CompilerServices::ITuple
[System.Serializable]
public struct ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> : IComparable, IComparable<ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>>, IEquatable<ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>>, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable, System.Runtime.CompilerServices.ITuple where TRest : struct
type ValueTuple<'T1, 'T2, 'T3, 'T4, 'T5, 'T6, 'T7, 'Rest (requires 'Rest : struct)> = struct
    interface ITuple
Public Structure ValueTuple(Of T1, T2, T3, T4, T5, T6, T7, TRest)
Implements IComparable, IComparable(Of ValueTuple(Of T1, T2, T3, T4, T5, T6, T7, TRest)), IEquatable(Of ValueTuple(Of T1, T2, T3, T4, T5, T6, T7, TRest)), IStructuralComparable, IStructuralEquatable, ITuple

类型参数

T1

值元组的第 1 个元素的类型。The type of the value tuple's first element.

T2

值元组的第 2 个元素的类型。The type of the value tuple's second element.

T3

值元组的第 3 个元素的类型。The type of the value tuple's third element.

T4

值元组的第 4 个元素的类型。The type of the value tuple's fourth element.

T5

值元组的第 5 个元素的类型。The type of the value tuple's fifth element.

T6

值元组的第 6 个元素的类型。The type of the value tuple's sixth element.

T7

值元组的第 7 个元素的类型。The type of the value tuple's seventh element.

TRest

泛型值元组实例,用于定义元组剩下元素的类型。Any generic value tuple instance that defines the types of the tuple's remaining elements.

继承
ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>
属性
实现
IStructuralComparable IStructuralEquatable IComparable IComparable<ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>> IEquatable<ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>> ITuple

注解

值元组是具有特定数量和值序列的数据结构。A value tuple is a data structure that has a specific number and sequence of values. @No__t-0 结构表示具有八个或更多元素的值元组。The ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> structure represents a value tuple that has eight or more elements.

值元组类型不同于元组类型(如 Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>),如下所示:The value tuple types differ from the tuple types (such as Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>) as follows:

  • 它们是结构(值类型)而不是类(引用类型)。They are structures (value types) rather than classes (reference types).

  • 成员(例如 Item1 和 @no__t)是字段而不是属性。Members such as Item1 and Item2 are fields rather than properties.

  • 它们的字段是可变的,而不是只读的。Their fields are mutable rather than read-only.

值元组类型提供支持中的元组C# 和中F#的结构元组的运行时实现。The value tuple types provide the runtime implementation that supports tuples in C# and struct tuples in F#. 除了使用语言语法创建 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例外,还可以调用 @no__t 的工厂方法。In addition to creating a ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance by using language syntax, you can call the ValueTuple.Create<T1,T2,T3,T4,T5,T6,T7,T8>(T1, T2, T3, T4, T5, T6, T7, T8) factory method.

序列化和值元组Serialization and value tuples

在 .NET Core 1.x 或 .NET Framework 4.7 及更早版本中,@no__t 0 类型无法序列化。The ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> type is not serializable in .NET Core 1.x or in the .NET Framework 4.7 and earlier versions. 此外,.NET Standard (包括 .NET Standard 2.0)不会强制执行 @no__t 0 实例的序列化;能否序列化 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例取决于单个 .NET Standard 实现。In addition, .NET Standard, including .NET Standard 2.0, does not mandate serialization of ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instances; whether or not a ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance is serializable depends on the individual .NET Standard implementation. 若要确定在特定 .NET 实现上是否可以序列化 @no__t 0 类型,请获取表示 @no__t 类型的 @no__t 1 对象,并检索其 @no__t 属性的值。To determine whether a ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> type is serializable on a particular .NET implementation, get a Type object that represents the ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> type and retrieve the value of its IsSerializable property. 有关 .NET Core 和 .NET Framework 中的可序列化类型的列表,请参见二进制序列化For a list of serializable types in .NET Core and the .NET Framework, see Binary Serialization.

构造函数

ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>(T1, T2, T3, T4, T5, T6, T7, TRest)

初始化一个新 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例。Initializes a new ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance.

字段

Item1

获取当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例的第 1 个元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance's first element.

Item2

获取当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例的第 2 个元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance's second element.

Item3

获取当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例的第 3 个元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance's third element.

Item4

获取当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例的第 4 个元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance's fourth element.

Item5

获取当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例的第 5 个元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance's fifth element.

Item6

获取当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例的第 6 个元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance's sixth element.

Item7

获取当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例的第 7 个元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance's seventh element.

Rest

获取当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例的剩余元素。Gets the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance's remaining elements.

方法

CompareTo(ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>)

将当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例与指定的 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例进行比较。Compares the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance to a specified ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance.

Equals(Object)

返回一个值,该值指示当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例是否与指定的对象相等。Returns a value that indicates whether the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance is equal to a specified object.

Equals(ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>)

返回一个值,该值指示当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例是否与指定的 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例相等。Returns a value that indicates whether the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance is equal to a specified ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance.

GetHashCode()

计算当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例的哈希代码。Calculates the hash code for the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance.

ToString()

返回表示此 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例的值的字符串。Returns a string that represents the value of this ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance.

显式界面实现

IComparable.CompareTo(Object)

比较当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 对象与指定对象,并返回一个整数,该整数指示当前对象在排序顺序中的位置:是在指定对象之前、之后还是在与指定对象相同的位置。Compares the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> object to a specified object 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.

IStructuralComparable.CompareTo(Object, IComparer)

使用指定的比较器比较当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例与指定对象,并返回一个整数,该整数指示当前对象在排序顺序中的位置:是在指定对象之前、之后还是在与指定对象相同的位置。Compares the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 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)

返回一个值,该值指示基于指定的比较方法,当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例是否与指定的对象相等。Returns a value that indicates whether the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance is equal to a specified object based on a specified comparison method.

IStructuralEquatable.GetHashCode(IEqualityComparer)

通过使用指定计算方法计算当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例的哈希代码。Calculates the hash code for the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance by using a specified computation method.

ITuple.Item[Int32]

获取指定 ValueTuple 元素的值。Gets the value of the specified ValueTuple element.

ITuple.Length

获取 ValueTuple 中的元素数。Gets the number of elements in the ValueTuple.

适用于

另请参阅