Đầu tiên, tạo một bộ giá trị như được hiển thị bên dưới để gọi một phương thức.
var tuple = Show();
Câu lệnh trên gọi phương thức sau -
static Tuple<int, int, int, int, int> Show()
Theo phương thức, trả về bộ giá trị như được hiển thị bên dưới -
Ví dụ
using System;
public class Demo {
public static void Main() {
var tuple = Show();
Console.WriteLine(tuple.Item1);
Console.WriteLine(tuple.Item2);
Console.WriteLine(tuple.Item3);
Console.WriteLine(tuple.Item4);
Console.WriteLine(tuple.Item5);
}
static Tuple<int, int, int, int, int> Show() {
return Tuple.Create(3, 5, 7, 9, 11);
}
} Đầu ra
3 5 7 9 11