You can't have a static variable inside a function, and I'm not sure I
understand why you would want one. You can place a static variable inside
the class, so the following class would work:
public class MyClass
{
static int i;
public void MyFunc()
{
//Do Something
}
}
--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com
"Ben S. Terry" <fake_email@spammers_suck.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Can someone please tell me how to declare a static variable in a function?
The following generates a compiler error:
public class MyClass
{
public void MyFunc()
{
static int i; // Compiler error: Invalid expression term 'static'
}
}