元組操作
16 個節點
本頁內容 16
比較
函數Orders two tuples of the same type element by element: the first position where they differ decides, as in sorting by several columns.
比較(左側: TTuple, 右側: TTuple) -> 整數
int Compare(TTuple left, TTuple right)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TTuple | — | The first tuple. |
| 右側 | TTuple | — | The second tuple. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
比較物件
函數Orders two values when you only have them as plain objects, using the left value's own comparison; null sorts before everything else.
比較物件(左側: 任意, 右側: 任意) -> 整數
int CompareObjects(object left, object right)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | 任意 | — | The first value; it must be comparable (as tuples, numbers and text are), or System.ArgumentException is thrown. Null sorts first. |
| 右側 | 任意 | — | The second value; it must be of a type the left value can compare against, or the left value's comparison throws (for a tuple, System.ArgumentException). |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
建立元組
函數過載 1/9
建立元組() -> ValueTuple
ValueTuple Create()
Makes the empty tuple, which holds no elements; it is the tuple form of "nothing", and every empty tuple equals every other.
返回
| 結果 | ValueTuple |
過載 2/9
建立元組(項 1: T1) -> (T1)
ValueTuple<T1> Create(T1 item1)
Makes a tuple holding one element.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 項 1 | T1 | — | The element. |
返回
| 結果 | (T1) |
過載 3/9
建立元組(項 1: T1, 項 2: T2) -> (T1, T2)
(T1, T2) Create(T1 item1, T2 item2)
Makes a pair: a tuple holding two elements, which may be of different types, for passing two related values along one wire.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 項 1 | T1 | — | The first element. |
| 項 2 | T2 | — | The second element. |
返回
| 結果 | (T1, T2) |
過載 4/9
建立元組(項 1: T1, 項 2: T2, 項 3: T3) -> (T1, T2, T3)
(T1, T2, T3) Create(T1 item1, T2 item2, T3 item3)
Makes a tuple holding three elements, which may be of different types.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 項 1 | T1 | — | The first element. |
| 項 2 | T2 | — | The second element. |
| 項 3 | T3 | — | The third element. |
返回
| 結果 | (T1, T2, T3) |
過載 5/9
建立元組 -> (T1, T2, T3, T4)
項 1: T1
項 2: T2
項 3: T3
項 4: T4(T1, T2, T3, T4) Create(T1 item1, T2 item2, T3 item3, T4 item4)
Makes a tuple holding four elements, which may be of different types.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 項 1 | T1 | — | The first element. |
| 項 2 | T2 | — | The second element. |
| 項 3 | T3 | — | The third element. |
| 項 4 | T4 | — | The fourth element. |
返回
| 結果 | (T1, T2, T3, T4) |
過載 6/9
建立元組 -> (T1, T2, T3, T4, T5)
項 1: T1
項 2: T2
項 3: T3
項 4: T4
項 5: T5(T1, T2, T3, T4, T5) Create(
T1 item1,
T2 item2,
T3 item3,
T4 item4,
T5 item5)Makes a tuple holding five elements, which may be of different types.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 項 1 | T1 | — | The first element. |
| 項 2 | T2 | — | The second element. |
| 項 3 | T3 | — | The third element. |
| 項 4 | T4 | — | The fourth element. |
| 項 5 | T5 | — | The fifth element. |
返回
| 結果 | (T1, T2, T3, T4, T5) |
過載 7/9
建立元組 -> (T1, T2, T3, T4, T5, T6)
項 1: T1
項 2: T2
項 3: T3
項 4: T4
項 5: T5
項 6: T6(T1, T2, T3, T4, T5, T6) Create(
T1 item1,
T2 item2,
T3 item3,
T4 item4,
T5 item5,
T6 item6)Makes a tuple holding six elements, which may be of different types.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 項 1 | T1 | — | The first element. |
| 項 2 | T2 | — | The second element. |
| 項 3 | T3 | — | The third element. |
| 項 4 | T4 | — | The fourth element. |
| 項 5 | T5 | — | The fifth element. |
| 項 6 | T6 | — | The sixth element. |
返回
| 結果 | (T1, T2, T3, T4, T5, T6) |
過載 8/9
建立元組 -> (T1, T2, T3, T4, T5, T6, T7)
項 1: T1
項 2: T2
項 3: T3
項 4: T4
項 5: T5
項 6: T6
項 7: T7(T1, T2, T3, T4, T5, T6, T7) Create(
T1 item1,
T2 item2,
T3 item3,
T4 item4,
T5 item5,
T6 item6,
T7 item7)Makes a tuple holding seven elements, which may be of different types.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 項 1 | T1 | — | The first element. |
| 項 2 | T2 | — | The second element. |
| 項 3 | T3 | — | The third element. |
| 項 4 | T4 | — | The fourth element. |
| 項 5 | T5 | — | The fifth element. |
| 項 6 | T6 | — | The sixth element. |
| 項 7 | T7 | — | The seventh element. |
返回
| 結果 | (T1, T2, T3, T4, T5, T6, T7) |
過載 9/9
建立元組 -> ValueTuple<T1, T2, T3, T4, T5, T6, T7, (T8)>
項 1: T1
項 2: T2
項 3: T3
項 4: T4
項 5: T5
項 6: T6
項 7: T7
項 8: T8ValueTuple<T1, T2, T3, T4, T5, T6, T7, ValueTuple<T8>> Create(
T1 item1,
T2 item2,
T3 item3,
T4 item4,
T5 item5,
T6 item6,
T7 item7,
T8 item8)Makes a tuple holding eight elements, which may be of different types.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 項 1 | T1 | — | The first element. |
| 項 2 | T2 | — | The second element. |
| 項 3 | T3 | — | The third element. |
| 項 4 | T4 | — | The fourth element. |
| 項 5 | T5 | — | The fifth element. |
| 項 6 | T6 | — | The sixth element. |
| 項 7 | T7 | — | The seventh element. |
| 項 8 | T8 | — | The eighth element. |
返回
| 結果 | ValueTuple<T1, T2, T3, T4, T5, T6, T7, (T8)> |
備註
The eighth element is stored in a nested one-element tuple (the Rest field), as every tuple of more than seven elements is; ValueTupleRoutines.Length, ValueTupleRoutines.Get and ValueTupleRoutines.ToArray look through the nesting and count it as eight elements.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
相等
函數Whether two tuples of the same type hold equal elements, position by position, using each element type's default equality.
相等(左側: TTuple, 右側: TTuple) -> 真否
bool Equals(TTuple left, TTuple right)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TTuple | — | The first tuple. |
| 右側 | TTuple | — | The second tuple. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
格式化
函數Writes a tuple as text, its elements separated by commas inside parentheses, for example (1, apple, True).
格式化(元組: 任意) -> 文字
string Format(object tuple)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 元組 | 任意 | — | The tuple to write. Null throws System.ArgumentNullException and a value that is not a tuple throws System.ArgumentException. |
返回
| 結果 | 文字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
取得項
函數The element at a position in a tuple, counting from zero; use ValueTupleRoutines.TryGet when the position may be out of range.
取得項(元組: 任意, 索引: 整數) -> 任意
object Get(object tuple, int index)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 元組 | 任意 | — | The tuple to read. Null throws System.ArgumentNullException and a value that is not a tuple throws System.ArgumentException. |
| 索引 | 整數 | — | The zero-based position; a position below zero or at or past the tuple's length throws System.IndexOutOfRangeException. |
返回
| 結果 | 任意 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
雜湊
函數A hash code combining the tuple's elements, so equal tuples get equal codes; use it for bucketing or quick inequality checks.
雜湊(元組: 任意) -> 整數
int Hash(object tuple)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 元組 | 任意 | — | The tuple to hash; null answers 0. |
返回
| 結果 | 整數 |
備註
The code is randomised per process, so do not store it or compare it across runs. This does not check that the value is a tuple: any other value answers its own hash code.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
是否為元組
函數Whether Value is a tuple, so the other tuple routines can read it.
是否為元組(值: 任意) -> 真否
bool IsTuple(object value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 任意 | — | The value to check; null answers false. |
返回
| 結果 | 真否 |
備註
This accepts any value that exposes its elements by position, which includes the older reference-type System.Tuple classes as well as value tuples; ValueTupleRoutines.IsTupleType is stricter and accepts only value tuple types.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
是否為元組型別
函數Whether Type is a value tuple type of any size, from the empty tuple up to seven elements plus a nested rest; for checking a type before you have a value of it.
是否為元組型別(型別: Type) -> 真否
bool IsTupleType(Type type)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 型別 | Type | — | The type to check; null answers false. The reference-type System.Tuple classes answer false. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
長度
函數How many elements a tuple holds, counting through the nested rest of a tuple with more than seven elements.
長度(元組: 任意) -> 整數
int Length(object tuple)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 元組 | 任意 | — | The tuple to measure. Null throws System.ArgumentNullException and a value that is not a tuple throws System.ArgumentException. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
結構比較
函數Orders two tuples element by element like ValueTupleRoutines.Compare, with Comparer ordering each pair of elements, for example to sort text elements case-insensitively.
結構比較(左側: 任意, 右側: 任意, 比較器: IComparer) -> 整數
int StructuralCompare(
object left,
object right,
IComparer comparer)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | 任意 | — | The first tuple; null or a value that does not support structural comparison throws System.ArgumentException. |
| 右側 | 任意 | — | The second tuple; null sorts before any tuple, and a tuple of a different type throws System.ArgumentException. |
| 比較器 | IComparer | — | The comparer that orders each pair of elements; null throws System.ArgumentNullException. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
結構相等
函數Whether two tuples hold equal elements, position by position, with Comparer deciding each pair, for example to compare text elements case-insensitively.
結構相等 -> 真否
左側: 任意
右側: 任意
比較器: IEqualityComparerbool StructuralEquals(
object left,
object right,
IEqualityComparer comparer)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | 任意 | — | The first tuple; null or a value that does not support structural comparison throws System.ArgumentException. |
| 右側 | 任意 | — | The second tuple; null, or a tuple of a different type, answers false. |
| 比較器 | IEqualityComparer | — | The comparer that decides whether two elements are equal; null throws System.ArgumentNullException. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
結構雜湊
函數A hash code for a tuple in which each element is hashed by Comparer, to pair with ValueTupleRoutines.StructuralEquals using the same comparer, for example to treat text elements case-insensitively.
結構雜湊(元組: 任意, 比較器: IEqualityComparer) -> 整數
int StructuralHash(object tuple, IEqualityComparer comparer)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 元組 | 任意 | — | The tuple to hash; null or a value that does not support structural comparison throws System.ArgumentException. |
| 比較器 | IEqualityComparer | — | The comparer that hashes each element; null throws System.ArgumentNullException. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
轉為陣列
函數Copies a tuple's elements into a new array in order, so they can be handled as a list.
轉為陣列(元組: 任意) -> 任意陣列
object[] ToArray(object tuple)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 元組 | 任意 | — | The tuple to copy. Null throws System.ArgumentNullException and a value that is not a tuple throws System.ArgumentException. |
返回
| 結果 | 任意陣列 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
嘗試取得項
函數Reads the element at a position in a tuple without throwing, telling you whether there was one.
嘗試取得項(元組: 任意, 索引: 整數) -> (結果: 真否, 值: 任意)
bool TryGet(object tuple, int index, out object value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 元組 | 任意 | — | The tuple to read; null or a value that is not a tuple answers false. |
| 索引 | 整數 | — | The zero-based position; out of range answers false. |
返回
| 結果 | 真否 |
| 值 | 任意 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫
驗證元組
函數Checks that a value is a tuple and throws if it is not, so a graph fails at a clear point instead of further on.
驗證元組(元組: 任意)
void ValidateTuple(object tuple)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 元組 | 任意 | — | The value to check. Null throws System.ArgumentNullException and a value that is not a tuple throws System.ArgumentException. |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 元組操作
- 所屬包
- 標準庫