Connecting Tech Pros Worldwide Help | Site Map

Array Declaration in C# use Count instead of UpperBound

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 16th, 2005, 09:41 PM
Annoyed Programmer
Guest
 
Posts: n/a
Default Array Declaration in C# use Count instead of UpperBound

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.



  #2  
Old November 16th, 2005, 09:41 PM
Glenn
Guest
 
Posts: n/a
Default Re: Array Declaration in C# use Count instead of UpperBound

So declaring the number of elements you require is counter-intuitive?

Glenn

"Annoyed Programmer" <Annoyed Programmer@discussions.microsoft.com> wrote in
message news:33244709-AFEB-4921-AB2D-DF5E04F89624@microsoft.com...[color=blue]
> Maybe this question has been addressed before, but I just stumbled with[/color]
the[color=blue]
> 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[/color]
the[color=blue]
> UpperBound declaration type.
>
> To me declare an array using count just seems counter-intuitive, maybe[/color]
it's[color=blue]
> just me.
>
> Would like to hear your comments, for me this is an issue which should be
> corrected.
>
>[/color]


  #3  
Old November 16th, 2005, 09:41 PM
Jay
Guest
 
Posts: n/a
Default Re: Array Declaration in C# use Count instead of UpperBound

"Annoyed Programmer" <Annoyed Programmer@discussions.microsoft.com> escreveu
na mensagem news:33244709-AFEB-4921-AB2D-DF5E04F89624@microsoft.com...[color=blue]
> 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[/color]
[color=blue]
> worked(Basic/VB/VB.NET/C/C++) was:[/color]
Wrong.
C/C++/Java use the number of elements.
[color=blue]
>
> (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,[/color]

[color=blue]
>maybe it's > just me.[/color]
I think so.
[color=blue]
>
> Would like to hear your comments, for me this is an issue which should be
> corrected.[/color]
No way.




  #4  
Old November 16th, 2005, 09:41 PM
Bruce Wood
Guest
 
Posts: n/a
Default Re: Array Declaration in C# use Count instead of UpperBound

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. :)

  #5  
Old November 16th, 2005, 09:41 PM
Cor Ligthert
Guest
 
Posts: n/a
Default Re: Array Declaration in C# use Count instead of UpperBound

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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.