VB6's private static in C# ?

Posted by blez on Stack Overflow See other posts from Stack Overflow or by blez
Published on 2010-04-30T22:23:45Z Indexed on 2010/04/30 22:27 UTC
Read the original article Hit count: 311

Filed under:
|
|
|

In VB6 there are local static variables that keep their values after the exit of procedure. It's like using public vars but on local block. For example:

sub count()
static x as integer
x = x + 1
end sub

After 10 calls, x will be 10. I tried to search the same thing in .NET (and even Java) but there was none. Why? Does it break the OOP model in some way, and is there a way to emulate that.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET