ValueTuple<T1,T2,T3,T4,T5,T6> ValueTuple<T1,T2,T3,T4,T5,T6> ValueTuple<T1,T2,T3,T4,T5,T6> ValueTuple<T1,T2,T3,T4,T5,T6> Struct

定義

表示含有 6 個元件的值元組。Represents a value tuple with 6 components.

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

類型參數

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.

T4

值元組第四個元素的類型。The type of the value tuple's fourth element.

T5

值元組第五個元素的類型。The type of the value tuple's fifth element.

T6

值元組第六個元素的類型。The type of the value tuple's sixth element.

繼承
ValueTuple<T1,T2,T3,T4,T5,T6>ValueTuple<T1,T2,T3,T4,T5,T6>ValueTuple<T1,T2,T3,T4,T5,T6>ValueTuple<T1,T2,T3,T4,T5,T6>
屬性
實作

備註

值元組是具有特定的數字和值序列的資料結構。A value tuple is a data structure that has a specific number and sequence of values. ValueTuple<T1,T2,T3,T4,T5,T6>結構代表具有六個元素的值元組。The ValueTuple<T1,T2,T3,T4,T5,T6> structure represents a value tuple that has six elements.

值元組類型不同的 tuple 型別 (例如Tuple<T1,T2,T3,T4,T5,T6>),如下所示:The value tuple types differ from the tuple types (such as Tuple<T1,T2,T3,T4,T5,T6>) as follows:

  • 它們是結構 (實值類型),而不是類別 (參考型別)。They are structures (value types) rather than classes (reference types).

  • 這類成員Item1Item2是欄位,而不是屬性。Members such as Item1 and Item2 are fields rather than properties.

  • 其欄位是可變動而非唯讀狀態。Their fields are mutable rather than read-only.

值元組類型提供支援的執行階段實作tuple 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>執行個體所使用的語言語法,您可以呼叫Createfactory 方法。In addition to creating a ValueTuple<T1,T2,T3,T4,T5,T6> instance by using language syntax, you can call the Create factory method.

序列化和值的 tupleSerialization and value tuples

ValueTuple<T1,T2,T3,T4,T5,T6>類型不是可序列化的.NET Core 1.x 或在.NET Framework 4.7 和舊版本。The ValueTuple<T1,T2,T3,T4,T5,T6> 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,不會要求您提供的序列化ValueTuple<T1,T2,T3,T4,T5,T6>執行個體; 是否ValueTuple<T1,T2,T3,T4,T5,T6>是可序列化的執行個體取決於個別的.NET Standard 實作。In addition, .NET Standard, including .NET Standard 2.0, does not mandate serialization of ValueTuple<T1,T2,T3,T4,T5,T6> instances; whether or not a ValueTuple<T1,T2,T3,T4,T5,T6> instance is serializable depends on the individual .NET Standard implementation. 若要判斷是否ValueTuple<T1,T2,T3,T4,T5,T6>型別是可序列化特定的.NET 實作上,會取得Type物件,表示ValueTuple<T1,T2,T3,T4,T5,T6>類型及擷取的值及其IsSerializable屬性。To determine whether a ValueTuple<T1,T2,T3,T4,T5,T6> type is serializable on a particular .NET implementation, get a Type object that represents the ValueTuple<T1,T2,T3,T4,T5,T6> 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>(T1, T2, T3, T4, T5, T6) ValueTuple<T1,T2,T3,T4,T5,T6>(T1, T2, T3, T4, T5, T6) ValueTuple<T1,T2,T3,T4,T5,T6>(T1, T2, T3, T4, T5, T6) ValueTuple<T1,T2,T3,T4,T5,T6>(T1, T2, T3, T4, T5, T6)

初始化新的 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體。Initializes a new ValueTuple<T1,T2,T3,T4,T5,T6> instance.

欄位

Item1 Item1 Item1 Item1

取得目前 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體第一個元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6> instance's first element.

Item2 Item2 Item2 Item2

取得目前 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體第二個元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6> instance's second element.

Item3 Item3 Item3 Item3

取得目前 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體第三個元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6> instance's third element.

Item4 Item4 Item4 Item4

取得目前 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體第四個元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6> instance's fourth element.

Item5 Item5 Item5 Item5

取得目前 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體第五個元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6> instance's fifth element.

Item6 Item6 Item6 Item6

取得目前 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體第六個元素的值。Gets the value of the current ValueTuple<T1,T2,T3,T4,T5,T6> instance's sixth element.

方法

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

比較目前的 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體與指定的 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體。Compares the current ValueTuple<T1,T2,T3,T4,T5,T6> instance to a specified ValueTuple<T1,T2,T3,T4,T5,T6> instance.

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

傳回值,這個值指出目前的 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體是否與指定的物件相等。Returns a value that indicates whether the current ValueTuple<T1,T2,T3,T4,T5,T6> instance is equal to a specified object.

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

傳回值,這個值指出目前的 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體是否與指定的 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體相等。Returns a value that indicates whether the current ValueTuple<T1,T2,T3,T4,T5,T6> instance is equal to a specified ValueTuple<T1,T2,T3,T4,T5,T6> instance.

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

計算目前 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體的雜湊碼。Calculates the hash code for the current ValueTuple<T1,T2,T3,T4,T5,T6> instance.

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

傳回字串,表示這個 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體的值。Returns a string that represents the value of this ValueTuple<T1,T2,T3,T4,T5,T6> instance.

明確介面實作

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

使用指定的比較子來比較目前的 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體與指定的物件,並傳回一個整數,指出目前的物件在排序次序中,是位於指定物件之前、之後或相同的位置。Compares the current ValueTuple<T1,T2,T3,T4,T5,T6> 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)

傳回值,這個值會根據指定的比較方法,指出目前的 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體是否與指定的物件相等。Returns a value that indicates whether the current ValueTuple<T1,T2,T3,T4,T5,T6> 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)

使用指定的計算方法,計算目前 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體的雜湊碼。Calculates the hash code for the current ValueTuple<T1,T2,T3,T4,T5,T6> instance by using a specified computation method.

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

使用指定的比較子來比較目前的 ValueTuple<T1,T2,T3,T4,T5,T6> 執行個體與指定的物件,並傳回一個整數,指出目前的物件在排序次序中,是位於指定物件之前、之後或相同的位置。Compares the current ValueTuple<T1,T2,T3,T4,T5,T6> 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]

取得指定的 ValueTuple 項目值。Gets the value of the specified ValueTuple element.

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

取得 ValueTuple 中的項目數目。Gets the number of elements in the ValueTuple.

Extension Methods

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

ValueTuple 結構的執行個體轉換為 Tuple 類別的執行個體。Converts an instance of the ValueTuple structure to an instance of the Tuple class.

適用於