ValueTuple<T1,T2,T3,T4,T5,T6,T7> 結構

定義

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

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

T7

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

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

備註

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

值元組類型不同于元組類型 (例如Tuple<T1,T2,T3,T4,T5,T6,T7>), 如下所示:The value tuple types differ from the tuple types (such as Tuple<T1,T2,T3,T4,T5,T6,T7>) 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.

值元組類型提供的執行時間執行, 可支援中的元組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>實例以外, 您還可以Create呼叫 factory 方法。In addition to creating a ValueTuple<T1,T2,T3,T4,T5,T6,T7> instance by using language syntax, you can call the Create factory method.

序列化和值元組Serialization and value tuples

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

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

欄位

Item1

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

Item2

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

Item3

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

Item4

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

Item5

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

Item6

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

Item7

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

方法

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

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

Equals(Object)

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

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

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

GetHashCode()

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

ToString()

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

明確介面實作

IComparable.CompareTo(Object)

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

IStructuralComparable.CompareTo(Object, IComparer)

使用指定的比較子來比較目前的 ValueTuple<T1,T2,T3,T4,T5,T6,T7> 執行個體與指定的物件,並傳回一個整數,指出目前的物件在排序次序中,是位於指定物件之前、之後或相同的位置。Compares the current ValueTuple<T1,T2,T3,T4,T5,T6,T7> 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> 執行個體是否與指定的物件相等。Returns a value that indicates whether the current ValueTuple<T1,T2,T3,T4,T5,T6,T7> instance is equal to a specified object based on a specified comparison method.

IStructuralEquatable.GetHashCode(IEqualityComparer)

使用指定的計算方法,計算目前 ValueTuple<T1,T2,T3,T4,T5,T6,T7> 執行個體的雜湊碼。Calculates the hash code for the current ValueTuple<T1,T2,T3,T4,T5,T6,T7> 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.

擴充方法

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

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

適用於