Tuple<T1> 類別

定義

表示 1-Tuple 或單一 (Singleton) 物件。Represents a 1-tuple, or singleton.

generic <typename T1>
public ref class Tuple : IComparable, System::Collections::IStructuralComparable, System::Collections::IStructuralEquatable
[System.Serializable]
public class Tuple<T1> : IComparable, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable
type Tuple<'T1> = class
    interface IStructuralEquatable
    interface IStructuralComparable
    interface IComparable
Public Class Tuple(Of T1)
Implements IComparable, IStructuralComparable, IStructuralEquatable

類型參數

T1

Tuple 之唯一元件的型別。The type of the tuple's only component.

繼承
Tuple<T1>
屬性
實作

備註

元組是一種資料結構, 具有特定的數目和值序列。A tuple is a data structure that has a specific number and sequence of values. Tuple<T1>類別代表1個元組, 或 singleton, 這是具有單一元件的元組。The Tuple<T1> class represents a 1-tuple, or singleton, which is a tuple that has a single component. Singleton 在應用程式開發中相當少使用。A singleton is used comparatively rarely in application development.

您可以藉由Tuple<T1>呼叫Tuple<T1>函式或靜態Tuple.Create方法來具現化物件。You can instantiate a Tuple<T1> object by calling either the Tuple<T1> constructor or the static Tuple.Create method. 您可以使用唯讀Item1實例屬性來抓取元組的單一元件值。You can retrieve the value of the tuple's single component by using the read-only Item1 instance property.

建構函式

Tuple<T1>(T1)

初始化 Tuple<T1> 類別的新執行個體。Initializes a new instance of the Tuple<T1> class.

屬性

Item1

取得 Tuple<T1> 物件之單一元件的值。Gets the value of the Tuple<T1> object's single component.

方法

Equals(Object)

傳回值,這個值表示目前的 Tuple<T1> 物件是否等於指定的物件。Returns a value that indicates whether the current Tuple<T1> object is equal to a specified object.

GetHashCode()

傳回目前 Tuple<T1> 物件的雜湊碼。Returns the hash code for the current Tuple<T1> object.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

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

明確介面實作

IComparable.CompareTo(Object)

將目前的 Tuple<T1> 物件與指定的物件進行比較,並且傳回一個整數,指出目前物件在排序順序中,究竟在指定物件的前面、後面還是相同位置。Compares the current Tuple<T1> 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)

使用指定的比較子將目前的 Tuple<T1> 物件和指定的物件進行比較,並且傳回一個整數,表示目前的物件在排序順序中位於指定之物件的前面、後面還是相的位置。Compares the current Tuple<T1> object 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)

傳回值,這個值表示依據指定的比較方法,目前的 Tuple<T1> 物件是否等於指定的物件。Returns a value that indicates whether the current Tuple<T1> object is equal to a specified object based on a specified comparison method.

IStructuralEquatable.GetHashCode(IEqualityComparer)

使用指定的計算方法,計算目前 Tuple<T1> 物件的雜湊碼。Calculates the hash code for the current Tuple<T1> object by using a specified computation method.

ITuple.Item[Int32]

取得 Tuple 項目值。Gets the value of the Tuple element.

ITuple.Length

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

擴充方法

Deconstruct<T1>(Tuple<T1>, T1)

將具有 1 個元素的元組解構為一個不同的變數。Deconstructs a tuple with 1 element into a separate variable.

ToValueTuple<T1>(Tuple<T1>)

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

適用於

另請參閱