var one = (x: 1, y: 2);
var two = (p: 1, 2: 3, r: 3, s:4);
要比较它们,只需使用 == 运算符 -
if (one == two)
Console.WriteLine("Both the tuples are same (values are same).");
登录后复制
让我们看看代码 -
示例
var one = (x: 1, y: 2);
var two = (p: 1, 2: 3, r: 3, s:4);
if (one == two)
Console.WriteLine("Both the tuples are same (values are same).");
lse
Console.WriteLine("Both the tuples values are not same.");
登录后复制
以上就是如何在 C# 中比较两个元组?的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!