基于泛型的对象实例构造方法
如何创建泛型空对象实例:
default(T)
如何创建泛型对象实例:
Activator.CreateInstance(typeof(T))
如何创建动态泛型对象实例:
Type listType = typeof(List<>).MakeGenericType(new Type[] { type });
IList listObjs = Activator.CreateInstance(listType) as IList;
如何创建泛型空对象实例:
default(T)
如何创建泛型对象实例:
Activator.CreateInstance(typeof(T))
如何创建动态泛型对象实例:
Type listType = typeof(List<>).MakeGenericType(new Type[] { type });
IList listObjs = Activator.CreateInstance(listType) as IList;
暂无评论。
评论功能维护中,当前仅展示历史评论。