If you want to choose what method or behavior you call at runtime based on a string, then try looking at interface and abstract class concepts. Based on their implementation, they can perform different functions.
interface ISomething
{
void DoSomething();
}
class SomethingA : ISomething
{
public void DoSomething()
{
Console.WriteLine("A");
}
}
class SomethingB : ISomething
{
public void DoSomething()
{
Console.WriteLine("B");
}
}
In the execution, you can check for the string and create a type of the object accordingly of SomethingA or SomethingB and call the method.
static void Main(string[] args)
{
ISomething obj;
if(args[0] == "Program1")
{
obj = new SomethingA();
}
else
{
obj = new SomethingB();
}
obj.DoSomething();
}
If you want to create a folder in DoSomething method with a name based on the string, look at How to create a folder
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…