Array Declaration in C# use Count instead of UpperBound

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Annoyed Programmer

    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.


  • Glenn

    #2
    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@disc ussions.microso ft.com> wrote in
    message news:33244709-AFEB-4921-AB2D-DF5E04F89624@mi crosoft.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]


    Comment

    • Jay

      #3
      Re: Array Declaration in C# use Count instead of UpperBound

      "Annoyed Programmer" <Annoyed Programmer@disc ussions.microso ft.com> escreveu
      na mensagem news:33244709-AFEB-4921-AB2D-DF5E04F89624@mi crosoft.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.




      Comment

      • Bruce Wood

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

        Comment

        • Cor Ligthert

          #5
          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


          Comment

          Working...