[英]Naming Convention: Non-Generic
If the following is a generic object: 如果以下是通用对象:
public class Kennel<T>
{
public List<T> Animals { get; set; }
}
This would be a non-generic object:\\ 这将是一个非通用对象:\\
public class Kennel
{
public List<Dog> Animals { get; set; }
}
Is there a good term for a non-generic class (aside from non-generic)? 非泛型类(除了非泛型类)是否有一个很好的用语?
There is no good term defined for what you want in the C# specification. 在C#规范中,没有为您想要的定义好的术语。 The specification defines: 规范定义:
An open type involves a type parameter; 开放类型涉及类型参数。 all non-open types are closed types. 所有非开放类型均为封闭类型。 So all non-generic types are closed types, but so is List<int>
. 因此,所有非泛型类型都是封闭类型, List<int>
也是封闭类型。 No type parameter in there; 那里没有类型参数; int
is a type argument . int
是类型参数 。 List<T>
is an open type. List<T>
是开放类型。
An unbound type is either a non-generic type or the type of a declaration of a generic type. 未绑定类型可以是非泛型类型,也可以是泛型类型的声明类型。 Like if you say class C<T>
then the abstract notion of " C
-of-one-type-parameter" is an unbound type, and C<int>
is a bound type. 就像您说class C<T>
,抽象概念“ C
的一个类型参数”是未绑定的类型,而C<int>
是绑定的类型。 Non-generic types are both bound and unbound, so that doesn't help you either. 非泛型类型是绑定的和未绑定的,因此也无济于事。 Note that in class C<T> { public static C<T> c; }
注意,在class C<T> { public static C<T> c; }
class C<T> { public static C<T> c; }
the second C<T>
is a bound type; class C<T> { public static C<T> c; }
第二个C<T>
是绑定类型; the type parameter has been supplied and it is T
. 提供了type参数,它是T
The C# specification just uses "non-generic" whenever that is meant. C#规范仅在需要时才使用“非泛型”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.