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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top