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?
Your statement is incorrect, hence your confusion. C# does allow structs to derive from classes. All structs derive from the same class, System.ValueType
So let's try this:
struct MyStruct : System.ValueType
{
}
This will not even compile. Compiler will remind you "Type 'System.ValueType' in interface list is not an interface".
When decompile Int32 which is a struct, you will find :
public struct Int32 : IComparable, IFormattable, IConvertible {}, not mentionning it is derived from System.ValueType. But in object browser, you do find Int32 does inherit from System.ValueType.
So all these lead me to believe:
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.