[C#] Declare variables (Resolved)

Started by Dweller, March 21, 2011, 04:36:01 pm

Previous topic - Next topic

Dweller

March 21, 2011, 04:36:01 pm Last Edit: March 22, 2011, 01:58:00 am by Dweller
I moving a game project from Visual Basic to Visual C#. I use global variables and arrays that loads in a Visual Basic module. Visual C# don´t have something like VB modules (at least I can´t find something similar). So to declare my global variables and arrays I made a GlobalClass and declare all of them inside it. Then I work with them using GlobalClass.variablename.

Is working fine but I´m not sure if this is a correct way to declare global variables in Visual C#. Is there something like VB modules in Visual C#? Is there a better way to declare global variables that inside a class?
Dwellercoc
Spoiler: ShowHide

G_G


Blizzard

C# is a pure object oriented language so everything has to go into a class.
The link G_G gave you shows you how to declare a static class and static variables inside. This is basically a better structured way to use a global variable.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Dweller

Dwellercoc
Spoiler: ShowHide