简体   繁体   中英

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. IEnumerable<T> supports a single type parameter. If you were to look at Dictionary<TKey, TValue> you would notice an arity value of 2.

Within the .NET type system, it is necessary that types have unique names. 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. 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]. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM