टपल तुलना C# 7.3 के बाद आई।
C# में इक्वैलिटी ऑपरेटर का उपयोग करके दो टपल्स की आसानी से तुलना करें।
मान लीजिए हमारे पास दो टपल्स हैं:
var one = (x: 1, y: 2); var two = (p: 1, q: 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, q: 3, r: 3, s: 4); if (one == two) Console.WriteLine("Both the tuples are same (values are same)."); else Console.WriteLine("Both the tuples values are not same.");