So I have classes that are for different versions and have like like.
csharp Code:
interface TheInterface
{
void AFunc();
}
//Version 1 uses this
class ClassA : TheInterface
{
void AFunc()
{
//stuff here
}
}
//Version 2 uses this
class ClassB : TheInterface
{
void AFunc()
{
//stuff here
}
}
//etc
I want to easily use the different classes based on a string.
Currently I am doing
csharp Code:
string ver = "1.0";
TheInterface inter;
if (ver == "1.0")
inter = (TheInterface)ClassA;
else if (ver == "2.0")
inter = (TheInterface)ClassB;
else
//unsupported
Is there a neater way of doing that?