开发者

Successor of int32

开发者 https://www.devze.com 2022-12-31 12:31 出处:网络
What is an immediate inheritor of int32 in C#?Is it int or int16? By inh开发者_如何学Goeritance, I mean given class A : B {} then class A is my class, and class B is a class that I inherit.Assuming y

What is an immediate inheritor of int32 in C#? Is it int or int16?

By inh开发者_如何学Goeritance, I mean given class A : B {} then class A is my class, and class B is a class that I inherit.


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.


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


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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消