Suppose I have a list of many (say, 10) classes A1,..., A10 which all inherits from a base class `A` and I have a one-to-one mapping from them to 10 other classes B1,...,B10. I also have a generic class `MyClass<T>` And I wish to have a function `Func(A a)` which creates a `MyClass<B1>` instance if the input is an instance of `A1`, creates a `MyClass<B2>` instance if the input is an instance of `A2`, etc. I can do it using a switch statement but it gets messy if the number of classes grows. What is a good way of doing this?

Here is an concrete example: say the A classes are `Cat` and `Dog`, and the B classes are `Foo` and `Bar`, and I have another Generator class to generate these instances.

```
public class Generator{
    public Foo Generate(Cat c){ 
        // some code
    }

    public Bar Generate(Dog d){
        // some code
    }
}

```

and I have a generic class below

```
public class MyClass<T>{
   private T _t; 

   public MyClass(T t){
       this._t = t; 
   }
}

```

Now in the code I want to do something like this

```
Generator gen = new Generator(); 
dynamic animal = new Dog(); 
var result = gen.Generate(animal); // can be of type Foo or Bar  
var cl = new MyClass(result); // does not compile!

```

The last line does not compile because it is missing a generic type argument.

Please let me know if there's more details needed!