int32 的后继者
C# 中 int32 的直接继承者是什么?是int还是int16?
通过继承,我的意思是给定class A : B {}
,那么A类是我的类,B类是我继承的类。
What is an immediate inheritor of int32 in C#? Is it int or int16?
By inheritance, I mean given class A : B {}
then class A is my class, and class B is a class that I inherit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
假设您正在谈论继承(不是很清楚)...
System.ValueType
,有效 - 或什么都没有,取决于您的观点。请注意,
int
和System.Int32
是同一类型;第一个是另一个的别名。值类型(例如
int
)隐式继承自System.ValueType
(或System.Enum
),并且不能从其他任何类型继承。Assuming you're talking about inheritance (it's not terribly clear)...
System.ValueType
, effectively - or nothing, depending on your viewpoint.Note that
int
andSystem.Int32
are the same type; the first is an alias for the other.Value types (such as
int
) implicitly inherit fromSystem.ValueType
(orSystem.Enum
) and can't inherit from anything else.基本类型是
ValueType
。此外,它还实现了接口
IComparable
、IComparable
、IConvertible
、IEquatable
、IFormatable
。The basetype is
ValueType
.Additionally it implements the interfaces
IComparable
,IComparable<int>
,IConvertible
,IEquatable<int>
,IFormatable
.不确定这个问题,但 C# 有以下数据类型:
System.Int16
(可以使用关键字short
),16位System.Int32
(可以使用关键字int
),32位它们是值类型,因此两者都不能继承除
System.ValueType
之外的任何类型,两者之间没有继承关系。Not sure on the question, but C# has the following datatypes:
System.Int16
(keywordshort
can be used), 16bitSystem.Int32
(keywordint
can be used), 32bitThey are value types so neither can inherit from anything other than
System.ValueType
, there is no inheritance between the two.关键字
int
是System.Int32
的别名。由于 System.Int32 是一个结构体,因此它没有子类型。与所有结构一样,它的直接超类型是System.ValueType
(它本身具有超类型System.Object
。)Int16
(也称为关键字 < code>short) 也是一个结构体,因此没有子类型和超类型System.ValueType
。它与int
和Int32
没有类型关系。The keyword
int
is an alias forSystem.Int32
. SinceSystem.Int32
is a struct, it has no subtypes. Like all structs, its immediate supertype isSystem.ValueType
(which itself has supertypeSystem.Object
.)Int16
(also known by the keywordshort
) is also a struct, so has no subtypes, and supertypeSystem.ValueType
. It has no type relation toint
andInt32
.来自 MSDN:
虽然我不确定我是否很好地理解了你的问题。如果您正在寻找 Int32 的子级,我认为没有 这里指出的。
From MSDN:
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.
我不明白这个问题,但
int
只是Int32
的别名,因此通过消除过程,您问题的答案可能是int16
。I don't understand the question but
int
is just an alias forInt32
so by the process of elimination the answer to your question is probablyint16
.