In C# what is the meaning of 1 after IEnumerable in System.Collections.Generic.IEnumerable`1

我的未来我决定 提交于 2019-12-23 07:58:07

问题


What is the meaning of 1 after IEnumerable in: System.Collections.Generic.IEnumerable`1


回答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.




回答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 (e.g. 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.



来源:https://stackoverflow.com/questions/16768208/in-c-sharp-what-is-the-meaning-of-1-after-ienumerable-in-system-collections-gene

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!