Alternatives to global variables

untwisted

New member
Joined
Jul 19, 2003
Messages
3
Location
Pittsburgh
Hi,

Ive run into another problem. How can I get around the no global variable rule in C#. I need to make a counter type variable, and it needs scope throughout my program.

Thanks!
 
Put it in a class, public and shared (static in C#).

C#:
public class Globals {
  public static Int32 myGlobal = 4;
}
Then access it like this:
C#:
Globals.myGlobal = 4;
 

Similar threads

Back
Top