如何创建泛型空对象实例:
default(T)
如何创建泛型对象实例:
Activator.CreateInstance(typeof(T))
如何创建动态泛型对象实例:
Type listType = typeof(List<>).MakeGenericType(new Type[] { type });
IList listObjs = Activator.CreateInstance(listType) as IList;
本文介绍了在C#中创建泛型实例的方法,包括默认泛型实例、特定类型的泛型实例及动态泛型对象实例的创建过程。
如何创建泛型空对象实例:
default(T)
如何创建泛型对象实例:
Activator.CreateInstance(typeof(T))
如何创建动态泛型对象实例:
Type listType = typeof(List<>).MakeGenericType(new Type[] { type });
IList listObjs = Activator.CreateInstance(listType) as IList;

被折叠的 条评论
为什么被折叠?