十一、泛型

一、泛型

where 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/fger/p/10655926.html