Whats the Diff?

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

    Whats the Diff?

    What is the difference between these two statements?

    Dim OutData() as Byte
    Dim OutData as [Byte]()

    I'm not seeing it...

    --
    Thanks
    Sueffel
  • Armin Zingler

    #2
    Re: Whats the Diff?

    "Sueffel" <someone@somewh ere.com> schrieb[color=blue]
    > What is the difference between these two statements?
    >
    > Dim OutData() as Byte
    > Dim OutData as [Byte]()
    >
    > I'm not seeing it...[/color]

    In the first line, the brackets are after "OutData", in the second line
    after "[Byte]".

    ..... oh .... you mean the different meanings? ;-) There is no difference.
    Both are equal. BTW, you don't need the "[" and "]".

    --
    Armin




    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Whats the Diff?

      * "Sueffel" <someone@somewh ere.com> scripsit:[color=blue]
      > What is the difference between these two statements?
      >
      > Dim OutData() as Byte
      >
      > Dim OutData as [Byte]()[/color]

      There is no difference, both will declare a byte array. But why do you
      use the square brackets?

      More information on the square brackets:

      <http://msdn.microsoft. com/library/en-us/vbls7/html/vblrfVBSpec2_2. asp>

      --
      Herfried K. Wagner [MVP]
      <http://www.mvps.org/dotnet>

      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: Whats the Diff?

        Sueffel,
        There is no difference, they both declare an array of bytes.

        The [] in the second one is used to escape an identifier allowing you to use
        a keyword for an identifier. Seeing as the Byte identifier is the same as
        the Byte keyword, both are used to refer to the System.Byte type there is no
        reason to escape it. Where you need to use [] is when you are using a
        keyword to refer to an identifier and that keyword is not valid in that
        context, such as Enum.

        If [Enum].IsDefined(GetT ype(MyEnum), myValue) Then

        The () in both cases says you have an array. Whether you include the () on
        the identifier or the type is a matter of preference I normally include it
        on the identifier, unless I have to include it on the type (such as the
        return value of a property or function.

        Hope this helps
        Jay

        "Sueffel" <someone@somewh ere.com> wrote in message
        news:%23mBgFUZy DHA.2000@TK2MSF TNGP11.phx.gbl. ..[color=blue]
        > What is the difference between these two statements?
        >
        > Dim OutData() as Byte
        > Dim OutData as [Byte]()
        >
        > I'm not seeing it...
        >
        > --
        > Thanks
        > Sueffel
        >[/color]


        Comment

        • Sueffel

          #5
          Re: Whats the Diff?


          "Sueffel" <someone@somewh ere.com> wrote in message news:%23mBgFUZy DHA.2000@TK2MSF TNGP11.phx.gbl. ..
          What is the difference between these two statements?

          Dim OutData() as Byte
          Dim OutData as [Byte]()

          I'm not seeing it...

          --
          Thanks
          Sueffel

          I was wondering becuse I saw some sample code that had that decleration, and I wasn't sure if it was more efficient on speed or memory. Thank you for the clarification, I can go back to what I'm used to , dim OutData() as Byte and be happy!

          Thanks again everyone,
          Sueffel


          ---
          Outgoing mail is certified Virus Free.
          Checked by AVG anti-virus system (http://www.grisoft.com).
          Version: 6.0.542 / Virus Database: 336 - Release Date: 11/18/2003

          Comment

          Working...