How to Create a Global Variable
-
i did 2 forms at Visual Studio 2008 in C#. i want to save Number from the first form and to use it in another.. how can i create a Global variable?( that all forms have access to it. for example:
int Num=3
i want that Form1 and Form2 will can change "Num".
-
i did 2 forms at Visual Studio 2008 in C#. i want to save Number from the first form and to use it in another.. how can i create a Global variable?( that all forms have access to it. for example:
int Num=3
i want that Form1 and Form2 will can change "Num".
global variables are poor design. try the singleton pattern instead, or better yet if you're using this as a parameter alone and not part of a class structure put it into a settings file and you'll have the parameter application wide. Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.” -Edsger Dijkstra
-
i did 2 forms at Visual Studio 2008 in C#. i want to save Number from the first form and to use it in another.. how can i create a Global variable?( that all forms have access to it. for example:
int Num=3
i want that Form1 and Form2 will can change "Num".
you can use the static or shared keyword depending on the language that you are using.
Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my homepage Oracle Studios Discounted or Free Software for Students: DreamSpark - downloads.channel8.msdn.com MSDN Academic Alliance - www.msdnaa.com