App Module variable (VB-C#)

  • Thread starter Thread starter Anony
  • Start date Start date
A

Anony

Hi All,

I was used to have a few global variables in VB module, so that each form or
class can share the same value.
Now in C#, I don't know how to do it. Is there an easy way?

Thanks for any tip,
Anony
 
Hi,

The best thing you can do, tnstead of global variables, is to have a static members in a public class.
Create public classes with same name as your modules. Declare the variables using static keyword so that they are shared across all references to these vaiables.
for example.

public class MyModule
{
public static int myGlobalVar1;
public static string myGlobalVar2;
}

and use them as MyModule.myGlobalVar1 and MyModule.myGlobalVar2

thanks
Nithin P V
 
Back
Top