Friday, 27 November 2015

Why a C# struct cannot be inherited

A struct Is Implicitly Sealed
Every struct in C#, whether it is user-defined or defined in the .NET Framework, is sealed; meaning that you can’t inherit from it. A struct is sealed because it is a value type and all value types are sealed.
All value types implicitly inherit from the class System.ValueType, which, in turn, inherits from class object. It is not possible for any type to derive from a value type, and value types are thus implicitly sealed.

No comments:

Post a Comment