protected bool Equals(UserType other) { return IntProperty == other.IntProperty && string.Equals(StringProperty, other.StringProperty); }
static void Main(string[] args) { #region [TEST #1: SEARCH BY REFERENCE] var normalType1 = new NormalType(1, "Smith"); var normalType2 = new NormalType(0, "Brown"); var normalType3 = new NormalType(0, "Doe"); var normalCollection = new CustomCollection<NormalType, string, string> { {normalType1, "Tom", "value0"}, {normalType2, "Michael", "value1"}, {normalType3, "John", "value2"} }; var normalSearchResult1 = normalCollection[new NormalType(0, "Brown")].ToList(); Debug.Assert(normalSearchResult1.Count == 0); var normalSearchResult2 = normalCollection[normalType2].ToList(); Debug.Assert(normalSearchResult2.Count == 1); #endregion #region [TEST #2: SEARCH BY VALUE] var userType1 = new UserType(1, "Smith"); var userType2 = new UserType(0, "Brown"); var userType3 = new UserType(0, "Doe"); var userCollection = new CustomCollection<UserType, string, string> { {userType1, "Tom", "value0"}, {userType2, "Michael", "value1"}, {userType3, "John", "value2"} }; var userSearchResult = userCollection[new UserType(0, "Brown")].ToList(); Debug.Assert(userSearchResult.Count == 1); #endregion }