Why is Array.Length an int, and not an uint *

Question

Why is Array.Length an int, and not an uint. This bothers me (just a bit), because a length value can never by 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 explicity...

So the ultimate question is: is there any use for an unsigned int (uint)? Even Microsoft seems not to use them.

Answer

Unsigned int isn't CLS compliant and would therefore restrict usage of the property to those languages that do implement a UInt.

Update: See here:

Framework 1.1

http://msdn.microsoft.com/en-us/library/hfa3fa08(VS.71).aspx

Framework 2.0

http://msdn.microsoft.com/en-us/library/hfa3fa08(VS.80).aspx

< br > via < a class="StackLink" href=" http://stackoverflow.com/questions/6301/" >Why is Array.Length an int, and not an uint< /a>
Share on Google Plus

About Cinema Guy

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment