• C#泛型类型参数的约束规则


    where T : struct       The type parameter <T> must have System.ValueType in its chain
                    of inheritance; in other words, <T> must be a structure.

    where T : class         The type parameter <T> must not have System.ValueType in its
                    chain of inheritance (e.g., <T> must be a reference type).

    where T : new()        The type parameter <T> must have a default constructor. This is
                    helpful if your generic type must create an instance of the type
                    parameter because you cannot assume you know the format of
                    custom constructors. Note that this constraint must be listed last
                    on a multiconstrained type.

    where T : NameOfBaseClass   The type parameter <T> must be derived from the class specified
                      by NameOfBaseClass.

    where T : NameOfInterface    The type parameter <T> must implement the interface specified
                     by NameOfInterface. You can separate multiple interfaces as a
                     comma-delimited list.

  • 相关阅读:
    springboot动态修改日志级别
    加密算法之RSA算法
    关于 BeanDefinitionOverrideException的解析
    Hive基础知识总结
    Java中的字符串替换:replace/replaceAll/StringTemplate
    xxl-job简介&整体架构设计
    java启动springboot jar包后台不挂断运行
    java自定义线程名称
    idea2019.2.2版本激活
    Log4j的MDC机制如何在线程池中使用
  • 原文地址:https://www.cnblogs.com/zhnhelloworld/p/3044423.html
Copyright © 2020-2023  润新知