Chaos Project

Game Development => Sea of Code => Topic started by: Dweller on March 21, 2011, 04:36:01 pm

Title: [C#] Declare variables (Resolved)
Post by: Dweller on March 21, 2011, 04:36:01 pm
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?
Title: Re: [C#] Declare variables
Post by: G_G on March 21, 2011, 04:39:15 pm
I'm pretty sure you're doing it right. http://www.dotnetperls.com/global-variable
Title: Re: [C#] Declare variables
Post by: Blizzard on March 21, 2011, 04:50:26 pm
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.
Title: Re: [C#] Declare variables (Resolved)
Post by: Dweller on March 22, 2011, 01:57:34 am
Ok thanks for the help