This is because if you rewrite the Equals method without overwriting the GetHashCode method, a potential Bug may occur when you use the Dictionary class. Copy the code static Dictionary <Person, string> personValues = new Dictionary <Person, string> (); protected void Page_Load (object sender, EventArgs e) {AddPerson (); person mike = new Person ("Mike"); Response. write (personValues. containsKey (mike); // False} void AddPerson () {Person mike = new Person ("Mike"); personValues. add (mike, "mike"); Response. write (personValues. containsKey (mike); // True} output result of this code segment: Tru E False: copy the Code. This Code indicates that when AddPerson () is executed, the idCode = Mike's Person object is stored in the Dictionary, and then in the Page_Load method, similarly, a new Person object with idCode = Mike uses the ContainsKey method to search for whether the object Key exists. The result is that the object does not exist. You can ask, in the previous suggestion, we have rewritten the Equals method of the Person class. As long as the idCode is equal, we can think that they are equal, why can't I find Mike here? A: This is because the CLR has optimized the query for the Dictionary type. In fact, the query for the Value is based on the HashCode of the Key Value. CLR first calls the GetHashCode method of the Person type, and finds that this item is not overwritten at all. Therefore, it searches for the GetHashCode method of the Object, and the Object provides the default GetHashCode implementation for all CLR types, every new object, CLR will generate a fixed integer value for this object, which will not be changed during the object lifecycle. The default GetHashCode Implementation of the object is the HashCode of this integer value. Therefore, although the Mike value is equal, the HashCode is not equal. To fix this problem, you must override the GetHashCode method public override int GetHashCode () {return this. IDCode. getHashCode ();} further improved: the GetHashCode method has a problem. It returns an integer type, and the Capacity length of the integer type is far from meeting the length of the string. That is to say, if the values are different, the HashCode may be the same. To reduce the generation of the same HashCode, make an improved version: public override int GetHashCode () {return (System. reflection. methodBase. getCurrentMethod (). declaringType. fullName + "#" + this. IDCode ). getHashCode ();} summary: This suggestion should at least let me know about HashCode. Previously, ToSt was rewritten. The GetHashCode is often seen during the ring method.