Static keyword proper usage?

Viewed 3034

Regarding the static keyword.

Up to this point, via my own research, I have a general idea of what the static keyword is, but I feel that all these different descriptions and details have only confused me more. At the moment, I really don't feel that I know how to properly use "static"; it seems to be used differently between C# and VB.NET and applies differently within the language depending on what you are using it for…

While reading the MSDN article Static (Visual Basic) , many questions arose, specifically when I read this sentence:

Normally, a local variable in a procedure ceases to exist as soon as the procedure terminates. A static variable remains in existence and retains its most recent value.

  1. Is the VB.NET version of static the same as C# or Java, is the concept the same for most languages?

  2. If static retain a value within a class, and we are able to access that certain member, function without instantiating the class, is this safe to use loosely? In other words, should we keep a close eye when using static’s within classes? They remind me of global variables for some reason. Maybe I’m just being ignorant here and simply need more practice to understand their purpose.

  3. What are good scenarios where using static benefits and promotes reusability of code?

3 Answers
Related