方法一
在使用泛型的类后面加入一个 where T : new()
public class Example<T> where T : new()
{
public static T Get()
{
T t = new T();
...........
}
}
方法二
可以使用 System.Activator.CreateInstance<T>()
创建泛型实例对像
public class Example<T>
{
public static T Get()
{
T t = System.Activator.CreateInstance<T>();
.....
}
}