Base class struct struct in c #

http://msdn.microsoft.com/en-us/library/ah19swz4(v=VS.71).aspx

According to the link above ..... "Structures, however, are inherited from an object of a base class ..."

According to the link below http://msdn.microsoft.com/en-us/library/system.valuetype.aspx Struct is implemented after ValueType in the hierarchy.

"struct" is inferred from which class? Or does the compiler consider a "struct" reserved word to make any declaration using "struct" as a value type? There is no small thread in the general sense. Thanks for the help. Smith

+5
source share
1 answer

Hierarchies (passing class subtypes):

  • struct .. -> ValueType -> Object

  • class .. -> Object

Demo:

struct S {}
class C {}

// or see `is` as per Jeff Mercado comment
typeof(ValueType).IsAssignableFrom(typeof(S)); // True
typeof(object).IsAssignableFrom(typeof(S));    // True

typeof(ValueType).IsAssignableFrom(typeof(C)); // False
typeof(object).IsAssignableFrom(typeof(C));    // True
+6
source

All Articles