In Visual Basic .NET, I can see different keyword for the same(?) concept:
• methods Shared • properties Shared • class-level variables Shared BUT • 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.
Best Answer
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.
https://msdn.microsoft.com/en-us/library/z2cty7t8.aspx