Alex Rivera | Logout

How do ValueTypes derive from Object (ReferenceType) and still be ValueTypes?

Asked 2009-11-05T17:31:27.097
93

C# doesn't allow structs to derive from classes, but all ValueTypes derive from Object. Where is this distinction made?

How does the CLR handle this?

Edit
Report

1 Answer

22

Small correction, C# doesn't allow structs to custom derive from anything, not just classes. All a struct can do is implement an interface which is very different from derivation.

I think the best way to answer this is that ValueType is special. It is essentially the base class for all value types in the CLR type system. It's hard to know how to answer "how does the CLR handles this" because it's simply a rule of the CLR.

answered 2009-11-05T17:36:08.070

Your Answer