Static v/s Shared variables in VB.NET

Last post 07-04-2009 8:41 AM by shekhar.patidar. 3 replies.

Sort Posts:

  • Static v/s Shared variables in VB.NET

    06-22-2009, 3:18 AM

    hi to all,

       any body can explain me the exact diff b/t Static v/s Shared variables in VB.NET????

    thanks

    Best Regards,
    Shekhar Patidar | Programmer
    Cybersitesindia Tech. Pvt. Ltd. - E-Commerce|Web-Development|Multimedia
    Mob.No. - 09970807255
    Mumbai-60
  • Re: Static v/s Shared variables in VB.NET

    06-22-2009, 3:23 AM
    • All-Star
      118,919 point All-Star
    • XIII
    • Member since 07-01-2002, 3:59 AM
    • Essen, Belgium
    • Posts 13,249
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    Hi,

    in VB.NET the keyword Shared's the equivalent of C#s static keyword.

    Grz, Kris.

  • Re: Static v/s Shared variables in VB.NET

    06-22-2009, 3:38 AM
    Answer
    • Contributor
      5,095 point Contributor
    • gerrylowry
    • Member since 07-03-2008, 1:46 AM
    • alliston ontario canada
    • Posts 1,939

    Shekhar, please read these articles:

    http://msdn.microsoft.com/en-us/library/z2cty7t8.aspx
    Static (Visual Basic) :: Specifies that one or more declared local variables are to continue to exist and retain their latest values after termination of the procedure in which they are declared.

    http://msdn.microsoft.com/en-us/library/zc2b427x.aspx
    Shared (Visual Basic) :: Specifies that one or more declared programming elements are associated with a class or structure at large, and not with a specific instance of the class or structure.

    http://msdn.microsoft.com/en-us/library/35styb3a.aspx
    Lifetime in Visual Basic :: The lifetime of a declared element is the period of time during which it is available for use. Variables are the only elements that have lifetime. For this purpose, the compiler treats procedure parameters and function returns as special cases of variables. The lifetime of a variable represents the period of time during which it can hold a value. Its value can change over its lifetime, but it always holds some value.

    Regards,
    Gerry (Lowry)

    Gerry Lowry, Principal
    Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
    68 John W. Taylor Avenue
    Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com

    Websites:
    http://abilitybusinesscomputerservices.com
    http://gerrylowryprogrammer.com ~~ résumé & testimonials
    http://veganoccasions.com ~~ recipes
  • Re: Static v/s Shared variables in VB.NET

    07-04-2009, 8:41 AM

    Thanks,for replying my questions and my  problem is solved.

                 and your advice is welcomed in future.

                 

    Best Regards,
    Shekhar Patidar | Programmer
    Cybersitesindia Tech. Pvt. Ltd. - E-Commerce|Web-Development|Multimedia
    Mob.No. - 09970807255
    Mumbai-60
Page 1 of 1 (4 items)