In java types like bool
, int
etc are primitives, i.e. they are inherently different from reference types, that's why java provides facilities for boxing and unboxing primitive types.
But in microsoft CLR, value types inherit from System.ValueType
which itself inherits from System.Object
. So then why is there a need for boxing and unboxing in microsoft CLR?
One reason might be that ValueType
class provides some low level hacks which allow value types to be treated somewhat similar to C structs. But then, if value types are so different from reference types, why make ValueType
inherit from Object
?
Pardon me if I said something ignorant. I don't have much experience with language design. It's just that the type system of CLR doesn't look as coherent as that of java to me.