我在C#中有一个泛型类,它有2个数据类型public class ResolvedChainSubscriber < K, V>
,现在我必须创建这个类的实例,但其中一个参数的数据类型只能在运行时知道。我将它存储为&#34; Type Prototype&#34;
public static Object SubsciberTopic(Type ProtoType, Object obj)
{
Type[] type={Type.GetType("System.String"),ProtoType};
Type resolve = typeof(ResolvedChainSubscriber <,>).MakeGenericType(type);
Object obj1=Activator.CreateInstance(resolve);
//now i want to typecast the parameter obj and store it in the new variable obj1
obj1=(some statement here)obj;
}