0

Lets say I have the function Setup() inside these namespaces:

application.one.Setup();
application.two.Setup();
application.three.Setup();
...

Now I can call them like this:

myVar = "two";
switch(myVar) {
    case "one":
        application.one.Setup();
        break;
    case "two":
        application.two.Setup();
        break;
    case "three":
        application.three.Setup();
        break;
    ...
}

What would be so much more effective is calling them like this:

myVar = "two";
application.[myVar].Setup();

Not only would it be much less code, but it will also mean I don't have to maintain a lot of switches.

Is this possible and how to do it?

Espen
  • 3,607
  • 11
  • 48
  • 75

0 Answers0