Ant <An*@discussions.microsoft.com> wrote:
I tried both these but both were not accepted. This is in a button click
event.
Static int siMyStaticVar; // Error on Static (understandable - s not S)
static int siMyStaticVar2; // Error on int (?)
Thanks again. Getting into C# after VB6. I feel like I've been in an
accident & have lost all my motor skills :)
Are you trying to declare these as *local* variables? If so, there's no
direct equivalent to VB's local static variables in C#. Instead, you
need to make the variable part of the class - either as a static
variable or an instance variable, depending on your needs.
The reasoning for this is that a method doesn't logically have state -
only an object (or a type) does.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too