By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

Array Declaration in C# use Count instead of UpperBound

P: n/a
Maybe this question has been addressed before, but I just stumbled with the
issue so I'll post it here.

Since I can remember array declaration in any language I've
worked(Basic/VB/VB.NET/C/C++) was:

(Example in Basic-way)

Dim Arr('UpperBound') as Type
Ex. Dim Arr(0) as String gives you a String Array with 1 element

But in C# string arr[0] gives you 0 elements, meaning the syntax is now

Type Arr('Count');

I'll like to know who though it would be a wonderful thing to break the
natural flow of thought by doing this in C# while all the remaining .NET
languages (with the possible exception of J# which I haven't tried) use the
UpperBound declaration type.

To me declare an array using count just seems counter-intuitive, maybe it's
just me.

Would like to hear your comments, for me this is an issue which should be
corrected.
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
So declaring the number of elements you require is counter-intuitive?

Glenn

"Annoyed Programmer" <Annoyed Pr********@discussions.microsoft.com> wrote in
message news:33**********************************@microsof t.com...
Maybe this question has been addressed before, but I just stumbled with the issue so I'll post it here.

Since I can remember array declaration in any language I've
worked(Basic/VB/VB.NET/C/C++) was:

(Example in Basic-way)

Dim Arr('UpperBound') as Type
Ex. Dim Arr(0) as String gives you a String Array with 1 element

But in C# string arr[0] gives you 0 elements, meaning the syntax is now

Type Arr('Count');

I'll like to know who though it would be a wonderful thing to break the
natural flow of thought by doing this in C# while all the remaining .NET
languages (with the possible exception of J# which I haven't tried) use the UpperBound declaration type.

To me declare an array using count just seems counter-intuitive, maybe it's just me.

Would like to hear your comments, for me this is an issue which should be
corrected.

Nov 16 '05 #2

P: n/a
Jay
"Annoyed Programmer" <Annoyed Pr********@discussions.microsoft.com> escreveu
na mensagem news:33**********************************@microsof t.com...
Maybe this question has been addressed before, but I just stumbled with
the
issue so I'll post it here.

Since I can remember array declaration in any language I've worked(Basic/VB/VB.NET/C/C++) was: Wrong.
C/C++/Java use the number of elements.

(Example in Basic-way)

Dim Arr('UpperBound') as Type
Ex. Dim Arr(0) as String gives you a String Array with 1 element

But in C# string arr[0] gives you 0 elements, meaning the syntax is now

Type Arr('Count');

I'll like to know who though it would be a wonderful thing to break the
natural flow of thought by doing this in C# while all the remaining .NET
languages (with the possible exception of J# which I haven't tried) use
the
UpperBound declaration type.

To me declare an array using count just seems counter-intuitive,
maybe it's > just me. I think so.

Would like to hear your comments, for me this is an issue which should be
corrected.

No way.


Nov 16 '05 #3

P: n/a
The only language that declares arrays the way you state is VB. So,
what you're really asking is why don't all of the other languages in
..NET change to conform to the way VB does things.

So, yes: I think it's just you. :)

Nov 16 '05 #4

P: n/a
Annoyed Programmer

When this should be corrected it should in my opinion be in VB.

It is in my opinion crazy that

dim a(1) as string gives an array of 2 strings and that while that is the
only place it is done like that.

The problem is probably in the indexing. In VB is tried to start the
indexing in the more for people logical One, in the same way as we learn to
count.

In the C derived languages is not made direct the conversion from the
register Zero to the Human One, that legacy will probably never be solved.

(By the way I find One more logical however would be a while in big problems
when that would be done, because I am as well very much used to that
counting from Zero and than every time to subtract 1).

Just my thought,

Cor
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.