public interface B : A {};
public interface C : A {};
public interface IMyInterface<in T> where T : A {};
public class FirstImpl<T> : IMyInterface<T> where T : B {};
public class SecondImpl<T> : IMyInterface<T> where T : C {};
public static void Main()
Console.WriteLine("test1 " + test1.GetType().Name);
Console.WriteLine("test2 " + test2.GetType().Name);
public static IMyInterface<T> Create<T>() where T : A
if(typeof(B).IsAssignableFrom(typeof(T)))
var type = typeof(FirstImpl<>);
var boundType = type.MakeGenericType(typeof(T));
return (IMyInterface<T>) Activator.CreateInstance(boundType);
else if(typeof(C).IsAssignableFrom(typeof(T)))
var type = typeof(SecondImpl<>);
var boundType = type.MakeGenericType(typeof(T));
return (IMyInterface<T>) Activator.CreateInstance(boundType);
throw new ArgumentException("unknown type " + typeof(T).Name);