int in C# is an alias for Int32, and they behave exactly the same. One would usually use Int32, instead of int, for readability and explicitness. Now, unfortunately your question can’t really be answered with a simple yes or no answer. - int implicitly derives from the ValueType Type which itself derives from the Object Type. And so, in C#, all Types do in-fact derive from the Object Type.
But, since ValueType can not be explicitly derived from (because it is an Abstract Class), the compiler needs to , and does, inherently know that int implicitly inherits from ValueType. So int does derive from the Object Type, just not explicitly.
Though int is not a Reference Type, it can still be treated like one ( like a Type that derives explicitly from the Object Type ) through a process called boxing.
It is a bit confusing at first. Everywhere online, and in books, people say that with regards to C#: All Types derive from the Object Type, which is true, but in the case of certain ValueType Types they just don’t inherit explicitly.
Furthermore, ints, as well as other ValueTypes, are constructed using Structs - not Classes in the way Reference types are.
System.ValueType
is implied by thestruct
keyword. In other languages (e.g. Java) there is a distinction between objects and primitives, however in .NET the type system is unified. All non-pointer, non-interface types inherit fromSystem.Object
. – Vauntcourier