where T:class的含义( where约束)

1  public void Request<T>(List<T> EntityList)  where T : class  
2  {  
3    
4  }  
这是参数类型约束,指定T必须是Class类型。
 
.NET支持的类型参数约束有以下五种:
where T : struct                               | T必须是一个结构类型
where T : class                                | T必须是一个Class类型
where T : new()                               | T必须要有一个无参构造函数(构造函数约束
where T : NameOfBaseClass          | T必须继承名为NameOfBaseClass的类(基类约束)
where T : NameOfInterface             | T必须实现名为NameOfInterface的接口(接口约束


 
 
原文地址:https://www.cnblogs.com/Wcode/p/6377991.html