473,473 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1080
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Søren Nøhr Christensen | last post by:
Hi all! I was wondering how much overhead was involved in using a bitarray. In other words, how much space does an array of say 32bit use? snc
53
by: Neo | last post by:
Hi All, Is that true that size of a byte not necessarily 8-bit? What the std. says? If that true, then what will the size of an int, i mean what sizeof(int) should return? On my machine...
19
by: Jerry | last post by:
I am wondering what is the maximum size of memory that malloc() could handle. Is there any limitation on that? Where am I supposed to get this kind of information? Thank you everybody.
51
by: Pedro Graca | last post by:
I run into a strange warning (for me) today (I was trying to improve the score of the UVA #10018 Programming Challenge). $ gcc -W -Wall -std=c89 -pedantic -O2 10018-clc.c -o 10018-clc...
22
by: Chad | last post by:
Given the following code include <stdio.h> #include <stdlib.h> int main(void) { char *msg_list = {" apple", " orange", " grape" }; printf("name: %s \n", msg_list);
2
by: Harry | last post by:
Good Day To all, When i am declaring a array for e.g char ....it means i am declaring array of 45 characters each of which has a maximum,minimum value limit or range...for example in...
9
by: Notebooker | last post by:
Hello, I'm an intermediate noob reading-in data from ascii-file using an ifstream object. I have specified a c-style string buffer with size of type size_t and I am specifying to use this...
6
by: marktxx | last post by:
Although the C90 standard only mentions the use of 'signed int' and 'unsigned int' for bit-fields (use 'int' at your own risk) and C99 adds _Bool. It seems that most compilers create the size of...
36
by: James Harris | last post by:
Initial issue: read in an arbitrary-length piece of text. Perceived issue: handle variable-length data The code below is a suggestion for implementing a variable length buffer that could be used...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.