Overriding Equals method in Structs

前端 未结 6 568
-上瘾入骨i
-上瘾入骨i 2020-12-28 11:24

I\'ve looked for overriding guidelines for structs, but all I can find is for classes.

At first I thought I wouldn\'t have to check to see if the passed object was n

6条回答
  •  醉酒成梦
    2020-12-28 12:15

    I suppose, if one's using .NET 4.5, one can use the default implementation as noted in the documentation:

    When you define your own type, that type inherits the functionality defined by the Equals method of its base type.

    ValueType.Equals: Value equality; either direct byte-by-byte comparison or field-by-field comparison using reflection.

提交回复
热议问题