Why is Array.Length
an int, and not a uint
. This bothers me (just a bit) because a length value can never be negative.
This also forced me to use an int for a length-property on my own class, because when you specify an int-value, this needs to be cast explicitly...
So the ultimate question is: is there any use for an unsigned int (uint
)? Even Microsoft seems not to use them.
uint means “unsigned integer” while int means “signed integer”. Unsigned integers only contain positive numbers (or zero). In addition there two alias types: byte which is the same as uint8 and rune which is the same as int32 .
int is shorter to type than uint .
Using sizeof() function to Find Array Length in C++ Hence, if we simply divide the size of the array by the size acquired by each element of the same, we can get the total number of elements present in the array.
A long value is stored in 64-bit,with its first digit to show if it's a positive/negative number. while ulong is also 64-bit, with all 64 bit to store the number. so the maximum of ulong is 2(64)-1, while long is 2(63)-1. Save this answer.
Unsigned int isn't CLS compliant and would therefore restrict usage of the property to those languages that do implement a UInt
.
See here:
Framework 1.1
Introduction to the .NET Framework Class Library
Framework 2.0
.NET Framework Class Library Overview
Many reasons:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With