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
staticvariable remains in existence and retains its most recent value.
Is the VB.NET version of
staticthe same as C# or Java, is the concept the same for most languages?If
staticretain 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 usingstatic’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.What are good scenarios where using
staticbenefits and promotes reusability of code?