Interfaces: Prof. M Nataraja Suresh
Interfaces: Prof. M Nataraja Suresh
• you derive from that interface a new interface, IDerived, which hides
the property P with a new method P( ): Making property P hidden
Member Hiding - Possibility
• We can use explicit implementation for either the base property or
the derived method, (or) Explicit on both
Accessing Sealed Classes and Value Types
• it is preferable to access the methods of an interface through an
interface cast. The exception is with value types (e.g., structs) or with
sealed classes.
• In that case, it is preferable to invoke the interface method through
the object.
• When you implement an interface in a struct, you are implementing it
in a value type. When you cast to an interface reference, there is an
implicit boxing of the object.
• Unfortunately, when you use that interface to modify the object, it is
the boxed object, not the original value object, that is modified.