Đầu tiên, hãy đặt một tuple
var tuple = Tuple.Create(100, 200, 300);
Bây giờ, hãy chuyển tuple dưới dạng tham số phương thức -
Show(tuple);
Đây là phương pháp của chúng tôi.
static void Show(Tuple<int,int,int> tuple)
Bây giờ hãy gọi lần lượt các giá trị tuple như được hiển thị bên dưới -
Ví dụ
using System;
public class Program {
public static void Main() {
var tuple = Tuple.Create(100, 200, 300);
Show(tuple);
}
static void Show(Tuple<int,int,int> tuple) {
Console.WriteLine(tuple.Item1);
Console.WriteLine(tuple.Item2);
Console.WriteLine(tuple.Item3);
}
} Đầu ra
100 200 300