[英]In C# what is the meaning of 1 after IEnumerable in System.Collections.Generic.IEnumerable`1
在IEnumerable之后1
的含义是什么: System.Collections.Generic.IEnumerable`1
It is the generic arity of the type, or put another way, the number of type parameters a generic type supports. 它是该类型的通用arity,或换句话说,泛型类型支持的类型参数的数量。
IEnumerable<T>
supports a single type parameter. IEnumerable<T>
支持单个类型参数。 If you were to look at Dictionary<TKey, TValue>
you would notice an arity value of 2. 如果您要查看
Dictionary<TKey, TValue>
您会注意到arity值为2。
Within the .NET type system, it is necessary that types have unique names. 在.NET类型系统中,类型必须具有唯一的名称。 Although it is only possible to create instances of bound generic types (eg
IEnumerable<System.Int32>
or IEnumerable<System.String>
), the unbound generic type may be used in certain contexts. 虽然只能创建绑定泛型类型的实例(例如
IEnumerable<System.Int32>
或IEnumerable<System.String>
),但未绑定的泛型类型可以在某些上下文中使用。 Within the language C#, such type would be written as IEnumerable<>
but within the type system it is notated as IEnumerable~1
[~ used to avoid format problems]. 在C#语言中,这种类型将被写为
IEnumerable<>
但在类型系统中,它被标记为IEnumerable~1
[〜用于避免格式问题]。 Note that the name of the bound generic type starts with the name of the unbound type, so if the unbound generic were called IEnumerable<>
within the type system, the name of the bound generic would have to start with IEnumerable<>
, including the back-to-back less-than-greater-than signs . 请注意,绑定泛型类型的名称以未绑定类型的名称开头,因此如果未绑定泛型在类型系统中被称为
IEnumerable<>
,则绑定泛型的名称必须以IEnumerable<>
开头, 包括背靠背不到大于标志 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.