In Visual Basic .NET, I can see different keyword for the same(?) concept:

• methods                 Shared
• properties              Shared
• class-level variables   Shared
• local variables         Static

Why there is Static and not Shared in case of local variables? Does different keyword indicate a different concept? Or is it only due to historical reasons?

To be clear - I understand that both static and shared variables are allocated on heap instead of stack and retain their value independently of instances. I would expect the same keyword then.

  • 1
    This is the kind of thing only the Microsoft devs could answer IMO.
    – RubberDuck
    Commented Mar 4, 2015 at 15:30
  • 1
    @RubberDuck - Maybe we found one?
    – JeffO
    Commented Mar 4, 2015 at 16:58

1 Answer 1


Isn't it correct to say that if something is Shared then you know there will be only one instance of it throughout the whole application. However if something is Static then there could well be many live instances of class but each instance will retain it's own value after termination of the procedure it lives in? Conceptually they are different.


When you declare a static variable in a Shared procedure, only one copy of the static variable is available for the whole application. You call a Shared procedure by using the class name, not a variable that points to an instance of the class.

When you declare a static variable in a procedure that isn't Shared, only one copy of the variable is available for each instance of the class. You call a non-shared procedure by using a variable that points to a specific instance of the class.


  • 1
    Now I see what difference I was missing. Thanks for clarification. Keywords Shared and Static truly denote different concepts.
    – miroxlav
    Commented Mar 4, 2015 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.