So I have classes that are for different versions and have like like.

csharp Code:
  1. interface TheInterface
  2. {
  3.     void AFunc();
  4. }
  5.  
  6. //Version 1 uses this
  7. class ClassA : TheInterface
  8. {
  9.     void AFunc()
  10.     {
  11.         //stuff here
  12.     }
  13. }
  14. //Version 2 uses this
  15. class ClassB : TheInterface
  16. {
  17.     void AFunc()
  18.     {
  19.         //stuff here
  20.     }
  21. }
  22. //etc

I want to easily use the different classes based on a string.

Currently I am doing

csharp Code:
  1. string ver = "1.0";
  2. TheInterface inter;
  3. if (ver == "1.0")
  4. inter = (TheInterface)ClassA;
  5. else if (ver == "2.0")
  6. inter = (TheInterface)ClassB;
  7. else
  8. //unsupported

Is there a neater way of doing that?