如何在 C# 中將元組轉換為陣列?
首先,設定元組 -
Tuple<int, int> t = Tuple.Create(99,53);
現在,將元組轉換為陣列 -
int[] arr = new int[]{t.Item1, t.Item2};以下是將元組轉換為陣列的程式碼 -
示例
using System;
using System.Linq;
using System.Collections.Generic;
namespace Demo {
public class Program {
public static void Main(string[] args) {
Tuple<int, int> t = Tuple.Create(99,53);
int[] arr = new int[]{t.Item1, t.Item2};
foreach (int val in arr) {
Console.WriteLine(val);
}
}
}
}輸出
99 53
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP