简体   繁体   中英

Why doesn't ScriptReference override Equals?

I was wondering if there is a good reason for ScriptReference not to override Equals . It would certainly make life in ScriptReferenceCollection s easier (eg Contains ), would it not?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM