Similar to Object
being the ultimate base class, what is the root or base interface applied to all primitive types in c#?
I am suspecting it to be iConvertible
Similar to Object
being the ultimate base class, what is the root or base interface applied to all primitive types in c#?
I am suspecting it to be iConvertible
If you are referring to the built-in types like int
, long
, string
etc. then there isn't a single base class that is common to them all.
Types like int
, long
, float
all inherit from System.ValueType, but not all built-in types are value types - string
for example is a reference type and as such, does not inherit from System.ValueType
but from System.Object
.
You can find the full list of C# type keywords to their .NET class counterparts here
Be aware that IConvertible
is not a base class - it is an interface. You don't inherit from an interface, you implement it - in other words, an interface is merely a contract that a class needs to adhere to if it chooses to implement it.
If you look at the docs for the built-in types you'll find they all implement a range of interfaces, of which IConvertible
is one of them but it's not the base class of those types as mentioned above.