Reputation: 75
Section 3.7.1.2 Hiding Through Inheritance of the C# 4 specification discusses the ability for classes or structs to hide members through re-declaring names that were used in base classes.
This is all well and good, but I thought that one of the distinctions of structs was that they could not be inherited.
Upvotes: 2
Views: 130
Reputation: 1063013
struct
still inherits from object
, via ValueType
. You can new
(hide) a GetHashCode
, Equals
or ToString
method - however, it would be incredibly stupid to do so, as that would mean you can't override
it, which means it will always be a boxing call to use them (even when done as a constrained call).
So, in order:
struct
Upvotes: 6