I was wondering if there is a good reason for ScriptReference
not to override Equals
. It would certainly make life in ScriptReferenceCollection
s easier (e.g. Contains
), would it not?
views:
42answers:
2
A:
My guess is either the framework team forgot, which is unlikely but could occur. Or they just didn't see a need, normally with reference objects you don't override the Equals method unless you are using some kind of entity object that is expected to compare across different references, such as a string or a Uri. Granted it would have been easy to implement this because it only takes two values. So to be honest, I don't know why.
Nick Berardi
2009-07-13 12:55:37
+1
A:
It has too many properties that may vary to make it viable to use some form of value based equality.
Note also it isn't sealed hence its sub-types may introduce further properties which would invalidate any existing equality code and hence make equality testing even more complex.
AnthonyWJones
2009-07-13 13:07:26