Đầu tiên, hãy đặt một bộ tuple -
Tuple<int, int> t = Tuple.Create(99,53);
Bây giờ, chuyển đổi tuple thành một mảng -
int[] arr = new int[]{t.Item1, t.Item2}; Sau đây là mã để chuyển đổi một tuple thành một mảng -
Ví dụ
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);
}
}
}
} Đầu ra
99 53