public static void Main(string[] args) { Pair asd = new Pair(3, 4); Pair asdec = new Pair(3, 4); Pair qwe = new Pair(3, 5); Pair stringos = new Pair("str1", "str2"); Pair ofPairs = new Pair(qwe, stringos); Console.WriteLine("{0} ; Hash code: {1}", asd, asd.GetHashCode()); Console.WriteLine("{0} ; Hash code: {1}", qwe, qwe.GetHashCode()); Console.WriteLine("{0} ; Hash code: {1}", stringos, stringos.GetHashCode()); Console.WriteLine("{0} ; Hash code: {1}", ofPairs, ofPairs.GetHashCode()); Console.WriteLine(asd == asdec); Console.WriteLine(asd.Equals(asdec)); Console.WriteLine(qwe.Equals(asd)); }
static void Main(string[] args) { Pair<int, string> pair1 = new Pair<int, string>(20, "asd"); Pair<int, string> pair2 = new Pair<int, string>(20, "asd"); Pair<int, string> pair3 = new Pair<int, string>(20, "asdf"); Console.WriteLine(pair1.Equals(pair2)); Console.WriteLine(pair1 == pair2); Console.WriteLine(pair1 != pair2); Console.WriteLine(); Console.WriteLine(pair1.Equals(pair3)); Console.WriteLine(pair1 == pair3); Console.WriteLine(pair1 != pair3); Console.WriteLine(); Pair<char, string> pair4 = new Pair<char, string>('a', "blabla"); Console.WriteLine(pair4); Console.ReadKey(); }
static void Main() { Pair test = new Pair(1, 3); Pair test2 = new Pair(1, 3); Console.WriteLine(test.Equals(test2)); }