带有泛型的C#语法

Pet*_*r17 4 .net c# generics syntax

我有一个关于跟随变量声明的问题.那是什么意思?

List<string>.Enumerator enumerator
Run Code Online (Sandbox Code Playgroud)

List是泛型类型,其中string用作类型参数.之后怎么解释.Enumerator?

dig*_*All 8

List<T>在其中有一个嵌套类,称为Enumerator.

所以它的类型定义是List<T>.Enumerator(在你的情况下T是a string).

PS

其实,List<T>.Enumeratorstruct,不是class,反正类型定义是相同的.

事实上,对于所有嵌套类型,它始终是 OuterType.NestedType