首页 > 学院 > 开发设计 > 正文

whereT:class的含义

2019-11-14 14:09:54
字体:
来源:转载
供稿:网友
[csharp] view plaincopy
 
public class Reflect<T> 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的接口

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表