This is one of those questions that has calmed down in my head from the very first day of programming in VB as a whole. I have my own personal ideas about this, but I wonder what the general consensus is regarding the use of static variables.
Static Variable:
Public Function Whatever() as Boolean
Static Flag as Boolean
If not Flag then
' do something
Flag = True
end if
Return Something
End sub
VS:
Private variable:
Private Flag as Boolean
Public Function Whatever() as Boolean
If not Flag then
' do something
Flag = True
end if
Return Something
End sub
Unless someone else knows, the above are functionally equivalent, except that the "Private" flag is available for use elsewhere in the class.
Questions begin to arise with Statics .. how ..
Where are they stored .. when they are REALLY created and located, etc.
Obviously, the compiler adds them to the heap of data (I know the poor use of THAT words) for the class somehow ... But is there a penalty for this in terms of overhead, garbage collection, etc.
, , , .
- - ?
PS: , SO...
. , . , , , .
....
.
https://weblogs.asp.net/psteele/7717