Пример #1
0
 /// <summary>
 /// Determines whether the given object is equal to this instance.
 /// </summary>
 /// <param name="obj">The object to compare this instance to.</param>
 /// <returns>Whether obj is equal to this instance.</returns>
 public override bool Equals(object obj)
 {
     if (obj is AllEqual)
     {
         AllEqual x = (AllEqual)obj;
         return(this == x);
     }
     else
     {
         return(false);
     }
 }
Пример #2
0
        public void TestETwoInstancesSameLocation()
        {
            Dictionary <AllEqual, int> d = new Dictionary <AllEqual, int>();
            AllEqual k1 = new AllEqual(100);
            AllEqual k2 = new AllEqual(123);

            d.Add(k1, 7);
            int v;

            // Because all instances of AllEqual are equal to each other, the dictionary
            // should find k2 if it maps to the same array location as k1.
            Assert.That(d.TryGetValue(k2, out v), Is.True);
        }