One, reference type equality comparison:
A total of four comparison methods:
1:referenceequals () method, static method, that tests whether two references specify the same object. And that null equals NULL.
1 Class1 x,y;
2 x = new Class1 ();
3 y = new Class1 ();
4 bool B1 = ReferenceEquals (null,null);//true
5 bool B2 = ReferenceEquals (null,x);//false
6 bool B3 = ReferenceEquals (x,y);//false
2: Virtual Equals () method, virtual, can rewrite, compare objects by value.
3: Static Equals () method, two parameters, compared to them (and virtual equals () difference).
4: comparison operator = =, which can be viewed as an intermediate option between strict value comparisons and strict reference comparisons.
Two, value type equality comparison:
The theoretical value comparison can be compared with drinking the same method, except that the value type requires a boxing process. However, in the boxing process, each value is individually boxed,
Therefore, it is meaningless to always return false with refernceequal () comparing the value type.
Summary: By understanding the type of drinking and value types, you can understand how the above works. Now the concept of equals () is still a little blurry, and hopefully it will be understood in the application.