在C#中禁止为泛型类实现默认构造函数吗?
如果不是,为什么下面的代码不能编译?(当我删除<T>时,它会编译)
那么为泛型类定义默认构造函数的正确方式是什么呢?
public class Cell<T> 
{
    public Cell<T>()
    {
    }
}编译时错误:错误1类、结构或接口成员声明中的标记'(‘无效
发布于 2016-12-09 18:25:25
如果您需要将Type作为属性:
public class Cell<T>
{
    public Cell()
    {
        TheType = typeof(T);
    }
    public Type TheType { get;}
}https://stackoverflow.com/questions/9701106
复制相似问题