这是类型参数约束,.NET支持的类型参数约束有以下五种:
where T : struct                                T必须是一个结构类型
where T : class                                 T必须是一个类(class)类型,不能是结构(structure)类型
where T : new()                                T必须要有一个无参构造函数
where T : NameOfBaseClass           T必须继承名为NameOfBaseClass的类
where T : NameOfInterface              T必须实现名为NameOfInterface的接口

版权声明:本文为博主原创文章,欢迎转载,转载请注明出处。

相关文章:

  • 2022-01-12
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
  • 2022-02-26
相关资源
相似解决方案