.NET支持的类型参数约束有以下五种: where T : struct | T必须是一个结构类型 where T : class | T必须是一个类(class)类型,不能是结构(structure)类型 引用类型 where T : new() | T必须要有一个无参构造函数 可以被new() where T : NameOfBaseClass | T必须继承名为NameOfBaseClass的类 where T : NameOfInterface | T必须实现名为NameOfInterface的接口
泛型类型参数约束 <T> where T : class,new(){}
最新推荐文章于 2024-06-03 10:16:28 发布