Jim Thio Jim Thio - 7 months ago 33
Vb.net Question

What does static variable in general mean for various programming language and circumstances?

Static variables are usually: (in most programming languages) shared, persistent, and allocated on the code section of the program

But what does that have anything to do with the word static? What is so static about that? I thought

means doesn't change?

For example, in vb.net static is written shared and that means a member function that can be accessed without object instantiation. Static within function usually means that the variable life time is the life time of the whole program. It seems that static variables are stored on the code section of the computer. Am I correct in my understanding based on the example?


Well, I think the keyword is appropriate. It means the variable you declare as static will remain stored at the same location throughout the whole execution of your program.

I thought static means doesn't change

This corresponds to the const keyword. Const implies it doesn't change, static implies it doesn't "move", as to it stays stored at the same location.