0

Here is a screenshot of the code definition from metadata:

enter image description here

And no one can deny the fact that all types inherit from Object class, but that is not the case in the definition of the Int32 class (and other classes BTW) I know that VS is smarter than me, but I want to know how it can keep Object class as a parent if it is not present in the definition?

mshwf
  • 7,009
  • 12
  • 59
  • 133

1 Answers1

0

There’s even more interesting question: if Object is a class, hence a reference type, and all types in C# inherit from Object, how would some of them be value types then?

The answer is that not all types derive from Object explicitly. There’s reference types and value types. Value types implicitly inherit from the ValueType class (which is ‘class’ so should be a reference type but as we know all value types are not reference types which is pretty logically).

There’s a more deep separation of value and reference types so you can’t see them by going to the metadata. You can read more on this topic here: Is everything in .NET an object?

Community
  • 1
  • 1
Ivan Yurchenko
  • 3,762
  • 1
  • 21
  • 35