111,129
社区成员
发帖
与我相关
我的任务
分享
public static object CreateGeneric(Type generic, Type innerType, params object[] args)
{
Type specificType = generic.MakeGenericType(new System.Type[] { innerType });
return Activator.CreateInstance(specificType, args);
}
object genericList = CreateGeneric(typeof(List<>), typeof(EC));
public class MyClass
{
}
Type t = typeof(List<MyClass>).GetGenericArguments()[0];
Console.WriteLine(t.Name);
//输出
//MyClass