问题描述
为什么 Array.Length
int类型,而不是一个 UINT
。这个困扰我(只是有点),因为长度值不能负。
Why is Array.Length
an int, and not an uint
. This bothers me (just a bit), because a length value can never by negative.
这也迫使我对我自己的类使用int的长度属性,因为当你指定一个int值,这需要显式地转换......
This also forced me to use an int for a length-property on my own class, because when youspecify an int-value, this needs to be cast explicitly...
所以,最终的问题是:是有一个unsigned int任何使用( UINT
)?即使微软似乎没有使用它们。
So the ultimate question is: is there any use for an unsigned int (uint
)? Even Microsoft seems not to use them.
推荐答案
unsigned int类型不符合CLS,因此将限制财产的使用这些语言的实现做一个 UINT
。
Unsigned int isn't CLS compliant and would therefore restrict usage of the property to those languages that do implement a UInt
.
下面参见:
框架1.1
框架2.0
这篇关于为什么Array.Length一个int,而不是一个UINT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!