zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    [译]Vulkan教程(09)窗口表面
    [译]Vulkan教程(08)逻辑设备和队列
    [译]Vulkan教程(07)物理设备和队列家族
    Linux命令行文本工具
    go语言周边
    go第三方常用包
    Centos6安装gcc4.8及以上版本
    pyenv设置python多版本环境
    Redis慢日志
    PHP-CPP开发扩展(七)
  • 原文地址:https://www.cnblogs.com/zhnhelloworld/p/3044423.html
Copyright © 2011-2022 走看看