Rowie

Rowie

  • NA
  • 5
  • 0

Global variables

May 1 2010 10:59 AM
I got a question about variables in C#.

I am trying to save a variable in a different class. I use Add --> New Item --> Class (So it is a complete new class where I want to save my variables I need to use throughout my project). I use getters and setters to save them.

I call the class in Form1 by using: private GlobalVars globalVars = new GlobalVars();

Now when I press a button a new Form appears where I use the same statement else I can't access the class. But when
I try to access a variable by using e.g: globalVars.intClient.toString(); I always get 0. The variables have been reset.

How can I solve this problem ??

Answers (4)