Reputation: 3092
I have a question about following variable declaration. What does that mean?
List<string>.Enumerator enumerator
List is a generic type, where string serves as a type parameter. How to interpret the .Enumerator after that?
Upvotes: 4
Views: 319
Reputation: 57210
List<T>
has a nested class in it, called Enumerator
.
So the type definition of that is List<T>.Enumerator
(and in your case T
is a string
).
P.S.
Actually, List<T>.Enumerator
is a struct
, not a class
, anyway the type definition would be the same.
In fact for all nested types it's always OuterType.NestedType
Upvotes: 8
Reputation: 8691
Try this link, has all information about List.Enumerator: Enumerator at MSDN documentation
In essens the enumerator is used while looping over the list with for each: "Initially, the enumerator is positioned before the first element in the collection. At this position, Current is undefined. Therefore, you must call MoveNext to advance the enumerator to the first element of the collection before reading the value of Current."
Upvotes: 1