Is it possbile to make a variable global in C#?
Well, you can make a public static variable:
public static class Globals
{
public static string Foo;
}
However, I'd strongly urge you not to do this:
I'd urge you to try very hard to design away from globals. If you could tell us more about why you think you want a global variable, we may be able to give you some advice on how to avoid it in this particular case :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With