📜  元组参数名称 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:58.930000             🧑  作者: Mango

代码示例1
// Tuples cannot be assigned parameter names.
//Instead you could do something like this:

(string name, int id) user = ("jack", 1);
Console.WriteLine($"{user.name}, {user.id}");
// Output:
//    jack, 1

// When working with lists:

List<(string name, int id)> users = new List<(string, int)>();

users.Add(("jack", 1));
users.Add(("john", 2));

users.ForEach((x) =>
    Console.WriteLine($"{x.name}, {x.id}")):

// Output:
//    jack, 1
//    john, 2