471,310 Members | 985 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

Why the size of an array is a signed type?

Hi,

I am wondering why the size of { array, array-list, ... } is a signed
type instead of an unsigned type.

TIA.
Marco.
Dec 6 '05 #1
4 1023
> I am wondering why the size of { array, array-list, ... } is a signed
type instead of an unsigned type.


Because uint is not CLS compliant, and the BCL classes like Array have to be
usable from all languages, including those that do not support unsigned ints.
Mattias

Dec 6 '05 #2
I believe that this is primarily because unsighed types are not CLS
compliant, so there is no guarantee that a particular language will support
them (it is entirely optional, and a language can still call itself .NET
compatible without them) - and so these fundamental types would be unusable.
C# does support unsigned types, byt others (VB.NET? Can't remember 100%) do
not.

For this reason, you should usually try to avoid putting non-CLS-compliant
types into your public interface; if you put a CLSCompliant attribute (true)
against your assembly, the IDE will then provide a warning whenever you do
this, unless you put in a second attribute (false) against the relevant
method (or whatever) - this makes is very easy to track what is/isn't
CLS-compliant.

Marc

"Marco Segurini" <ma***********@virgilio.it> wrote in message
news:uQ***************@TK2MSFTNGP14.phx.gbl...
Hi,

I am wondering why the size of { array, array-list, ... } is a signed type
instead of an unsigned type.

TIA.
Marco.

Dec 6 '05 #3
CLS compliance. Either that or the devs were reading a bit too much Hawking.
:-)
(yes, that is obscure)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***********************************************
Think Outside the Box!
***********************************************
"Marco Segurini" <ma***********@virgilio.it> wrote in message
news:uQ***************@TK2MSFTNGP14.phx.gbl...
Hi,

I am wondering why the size of { array, array-list, ... } is a signed type
instead of an unsigned type.

TIA.
Marco.

Dec 6 '05 #4

"Marco Segurini" <ma***********@virgilio.it> wrote in message
news:uQ***************@TK2MSFTNGP14.phx.gbl...
Hi,

I am wondering why the size of { array, array-list, ... } is a signed type
instead of an unsigned type.

TIA.
Marco.


1. CLS compliancy, as correctly stated by the other repliers.
2. The size of an 'object' on the GC heap which is limitted to 2GB , this is
true for both 32 bit and 64 bit versions of the CLR. That means that the
largest array can only have 2^31 elements (minus a few bytes) anyway.

Willy.


Dec 6 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Søren Nøhr Christensen | last post: by
53 posts views Thread by Neo | last post: by
19 posts views Thread by Jerry | last post: by
51 posts views Thread by Pedro Graca | last post: by
2 posts views Thread by Harry | last post: by
6 posts views Thread by marktxx | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.