首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

where T : class的含意

2013-02-17 
where T : class的含义public void RequestT(ListT EntityList)where T : class{}这是参数类型约束,指

where T : class的含义

public void Request<T>(List<T> EntityList)  where T : class{}

这是参数类型约束,指定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的接口

 

 

热点排行