Why GetHashCode is not a property like HashCode in .NET?
Probably because it requires computation, and exposing it as a propery might imply that the hashcode is already available for free.
Edit: Guidelines on this: Properties versus Methods
"The operation is expensive enough that you want to communicate to the user that they should consider caching the result."
Perhaps GetHashCode is expensive enough in some cases.
I don't think there's any good reason. Any implemention of GetHashCode
should be fast enought to put into a property. That said, there are plenty of design flaws in the .Net framework, some small, some serious. This seems like a small one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With