码迷,mamicode.com
首页 > 其他好文 > 详细

public void Delete<T>(List<T> EntityList) where T : class, new() 这是什么意思

时间:2014-11-10 13:39:21      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   sp   div   log   bs   as   new   

就是说T必须是一个类(class)类型,不能是结构(structure)类型。

这是类型参数约束,.NET支持的类型参数约束有以下五种:


where T : struct                   T必须是一个结构类型


where T : class                     T必须是一个类    


where T : new()                    T必须要有一个无参构造函数


where T : NameOfBaseClass   T必须继承名为NameOfBaseClass的类


where T : NameOfInterface     T必须实现名为NameOfInterface的接口

 

public void Delete<T>(List<T> EntityList) where T : class, new() 这是什么意思

标签:style   blog   color   sp   div   log   bs   as   new   

原文地址:http://www.cnblogs.com/xyzhuzhou/p/4086941.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!