Variable initialisation

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

    #1

    Variable initialisation

    If you look at the following two pieces of code they perform exactly the
    same task

    Dim sMessage As String
    sMessage = "Hello!"

    Dim sMessage As String = "Hello!"

    Is there any difference "behind the scenes" where one of the following is
    preferable to the other, or is this just personal preference?




  • Mattias Sjögren

    #2
    Re: Variable initialisation

    [color=blue]
    >or is this just personal preference?[/color]

    Yep



    Mattias

    --
    Mattias Sjögren [MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    • Patrice

      #3
      Re: Variable initialisation

      Personnal preference (unlike VB6). You could look at the MSIL code to make
      sure...

      --

      "JohnFol" <OutlookExpress @WibbleObbble.C om> a écrit dans le message de
      news:FBGde.2365 $c4.1823@newsfe 3-win.ntli.net...[color=blue]
      > If you look at the following two pieces of code they perform exactly the
      > same task
      >
      > Dim sMessage As String
      > sMessage = "Hello!"
      >
      > Dim sMessage As String = "Hello!"
      >
      > Is there any difference "behind the scenes" where one of the following is
      > preferable to the other, or is this just personal preference?
      >
      >
      >
      >[/color]


      Comment

      • JohnFol

        #4
        Re: Variable initialisation

        thanks for the answers

        "JohnFol" <OutlookExpress @WibbleObbble.C om> wrote in message
        news:FBGde.2365 $c4.1823@newsfe 3-win.ntli.net...[color=blue]
        > If you look at the following two pieces of code they perform exactly the
        > same task
        >
        > Dim sMessage As String
        > sMessage = "Hello!"
        >
        > Dim sMessage As String = "Hello!"
        >
        > Is there any difference "behind the scenes" where one of the following is
        > preferable to the other, or is this just personal preference?
        >
        >
        >
        >[/color]


        Comment

        Working...