I have a csharp app with a xml config file containing an element called "environment" which can be set to different values (development/test/production for example).
When this config file entry is modified the resulting global variables within the application should all change. I have a class in my application called Globals were I am storing global variables. I want to add a case/switch element to it but it won't seem to work.
So for example I have the following defined at the top of the globals class:
public static string environment = MyApp.Properties.Settings.Default.Environment;
Then lower down in my class I'm trying to do the following:
switch (environment)
{
case "development":
public static string Server = "SQL1";
public static string Username = "dev.user";
case "test":
public static string Server = "SQL2";
public static string Username = "test.user";
case "production":
public static string Server = "SQL3";
public static string Username = "prod.user";
default:
public static string Server = "SQL1";
public static string Username = "dev.user";
}
(In the example above I reduced the number of variables to two just to make it more understandable but in reality there are probably 30 variables per environment.)
This doesn't work I get multiple errors:
Invalid token 'switch' in class, struct, or interface member declaration
Invalid token ')' in class, struct, or interface member declaration
Invalid token 'case' in class, struct, or interface member declaration
Is there some other way of doing this?
Thanks Brad