不能用基本类型实例化泛型类型参数。
Generic type parameters can't be instantiated with primitive types.
泛型类型参数和基本类型。
已知为引用类型的泛型类型参数。
泛型类型参数是类型的占位符。
如何匹配的泛型类型参数?
枚举不能有泛型类型参数。
添加显式泛型类型参数。
创建泛型类型参数的定义,并获取该泛型类型参数的标记。
Each parameter definition consists of a parameter name and a data type.
不要产生泛型类型参数的哈希值,使用一个易懂的类型名称作为替代。
Suppress the generation of a generic type parameter hash code and provide a legible type name instead.
泛型类型参数名称应以大写字母“T”开头,后面可跟另一个大写字母。
Generic type parameter names should start with an uppercase 't' and optionally may be followed by another uppercase letter.
外部可见的类型或方法上的泛型类型参数的名称不以大写的“T”开头。
The name of a generic type parameter on an externally visible type or method does not start with an uppercase 't'.
在由指定的泛型类型参数定义的上下文中,返回由指定的元数据标记标识的字段。
Returns the field identified by the specified metadata token, in the context defined by the specified generic type parameters.
在由指定的泛型类型参数定义的上下文中,返回由指定的元数据标记标识的类型。
Returns the type identified by the specified metadata token, in the context defined by the specified generic type parameters.
可以向逆变委托分配同一类型的其他委托,但需使用派生程度较小的泛型类型参数。
A contravariant delegate can be assigned another delegate of the same type, but with a less derived generic type parameter.
可以向协变委托分配同一类型的其他委托,但需使用派生程度较大的泛型类型参数。
A covariant delegate can be assigned another delegate of the same type, but with a more derived generic type parameter.
擦除的另一个后果是,对泛型类型参数是用强制类型转换或者instance of毫无意义。
Another consequence of erasure is that using casts or instanceof with generic type parameters doesn't make any sense. The following code will not improve the type safety of your code at all.
在将某一约束应用于泛型类型参数时,必须存在从具体参数到该约束类型的隐式标识或引用转换。
When a constraint is applied to a generic type parameter, an implicit identity or reference conversion must exist from the concrete argument to the type of the constraint.
返回由指定元数据标记标识的字段的运行时字段句柄,指定标记所在范围内的类型和方法的泛型类型参数。
Returns a runtime field handle for the field identified by the specified metadata token, specifying the generic type arguments of the type and method where the token is in scope.
返回由指定元数据标记标识的类型的运行时类型句柄,指定标记所在范围内的类型和方法的泛型类型参数。
Returns a runtime method handle for the method or constructor identified by the specified metadata token, specifying the generic type arguments of the type and method where the token is in scope.
因为运行时不能区分List和List(运行时都是List),用泛型类型参数标识类型的变量的构造就成了问题。
Because the runtime cannot tell a List from a List (at runtime, they're both just Lists), constructing variables whose type is identified by a generic type parameter is problematic.
务必使用描述性名称命名泛型类型参数,除非单个字母名称完全可以让人了解它表示的含义,而描述性名称不会有更多的意义。
Do name generic type parameters with descriptive names, unless a single letter name is completely self explanatory and a descriptive name would not add value.
要提高泛型代码的有效性,可以指定一个上限(或下限),而不是指定某个泛型类型参数的精确类型。 这可以使用有界通配符来实现,它的形式为 “?
To increase the usefulness of our generic code, instead of specifying the exact type of a generic type parameter, we can specify an upper (or lower) bound instead.
如果提供的类是泛型类,那么即使为这个类提供了最通用的参数类型定义,也会处理类的所有字段。
If that supplied class is a generic class, all fields of the class are processed as though the most general possible parameter type definitions were supplied for the class.
签名定义了泛型实际使用的参数类型,所以它提供了处理类型替换时需要的信息。
A signature defines the actual parameter types used with a generic type, so it provides the information I'll need to process type substitutions.
这个泛型类处理成对的值,类型参数给出了这些对中项目的类型。
This generic class handles pairs of values, with the type parameters giving the types of the items in the pairs.
此远程过程具有一个或多个泛型参数,或强类型参数。
This remote procedure can have one or more generic parameters, or strongly typed once.
可以将泛型类型看作是类型“函数”;它们通过类型变量进行参数化,这些类型变量可以根据上下文用各种类型参数进行实例化。
Generic types can be thought of as type "functions"; they are parameterized by type variables that can then be instantiated with various type arguments depending on context.
松散类型服务使用泛型参数定义,其中不以架构的形式包含消息内容的说明。
Loosely typed services use generic parameter definitions that do not include an explanation of the message content in form of a schema.
因此,当类型参数t用作泛型类的超类时,T的注释确切地告知我们可以调用哪些超级构造函数。
Thus, when a type parameter t is used as the superclass of a generic class, the annotation on t tells us exactly what super-constructors we can call.
再提一次,那是因为一个泛型类可以用其自己的类型参数来实例化另一个泛型类。
Again, that's because one generic class may instantiate another with its own type parameters.
应用推荐