Is it possible to override the GetHashCode method for a string, int, int32 etc..
I dont want to create a new object or class and override it that away. I wonder if there was a way to override the type’s method. Similar to an extension but not really.
string myString = "sometext";
myString.GetHashCode(); -- I want to override this method.
If you do not want to create your own class, then no because an override is only possible within a subclass.
An alternative would be to create a custom extension method like:
This would have a similar effect, but you would need to call
.GetHashCode2()rather than.GetHashCode()