tags:

views:

146

answers:

6

what is an immediate inheritor of int32 in C#? int or int16

+8  A: 

Assuming you're talking about inheritance (it's not terribly clear)...

System.ValueType, effectively - or nothing, depending on your viewpoint.

Note that int and System.Int32 are the same type; the first is an alias for the other.

Value types (such as int) implicitly inherit from System.ValueType (or System.Enum) and can't inherit from anything else.

Jon Skeet
+1  A: 

I don't understand the question but int is just an alias for Int32 so by the process of elimination the answer to your question is probably int16.

ho1
+2  A: 

Not sure on the question, but C# has the following datatypes:

System.Int16 (keyword short can be used), 16bit

System.Int32 (keyword int can be used), 32bit

They are value types so neither can inherit from anything other than System.ValueType, there is no inheritance between the two.

David Neale
+3  A: 

The basetype is ValueType.
Additionally it implements the interfaces IComparable, IComparable<int>, IConvertible, IEquatable<int>, IFormatable.

tanascius
+2  A: 

The keyword int is an alias for System.Int32. Since System.Int32 is a struct, it has no subtypes. Like all structs, its immediate supertype is System.ValueType (which itself has supertype System.Object.)

Int16 (also known by the keyword short) is also a struct, so has no subtypes, and supertype System.ValueType. It has no type relation to int and Int32.

Joren
+2  A: 

From MSDN:

All value types implicitly inherit from the class System.ValueType, which, in turn, inherits from class object.

Although I'm not exactly sure if I understood your question well. If you are looking for a child of Int32, I think there is none as indicated here.

Ondrej Slinták