Overriding these three methods is done for three different purposes:
- ToString: The output representation of the object.
- Equally: if two objects represent the same thing. Uses GetHashCode in its default implementation.
- GetHashCode: used to index objects. A few additional topics here, including semi-uniqueness and hash distribution.
As you can see, 2 and 3 are connected to each other, but 1 is separate. If you don't accept Equals just check if the ToString of the two objects are equal, which is likely to be a mistake. :)
So, the short answer is already set: you can override ToString without overriding the other two methods. It is quite normal to even overload the ToString method. See DateTime for an example: http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx
source share