Had this annoying bug today where something that seemed perfectly resonable just didn’t work. After much investigation it appears that once again brain damage from Java has managed to over into C#. The problem is illustrated with the following code (You can ignore the Tuple for now):
public struct Tuple < TFirst,TSecond > { public TFirst first; public TSecond second; public Tuple(TFirst first, TSecond second) { this.first = first; this.second = second; } } [...] Tuple < int,string > t = new Tuple < int,string >(1, "1"); Tuple < int,string > t2 = new Tuple < int,string >(2, "2"); List < tuple < int,string > > lt = new List < tuple < int,string > >(); lt.Add(t); lt.Add(t2); List < tuple < int,string > > lt2 = new List < tuple < int,string > >(); lt2.Add(t); lt2.Add(t2); System.Console.WriteLine("eq {0}, == {1}", lt.Equals(lt2), lt == lt2); Which gives the following result:
...