C # Syntax with Generics

I have a question about the next variable declaration. What does it mean?

List<string>.Enumerator enumerator 

A list is a generic type, where string serves as a type parameter. How to interpret .Enumerator after that?

+4
source share
2 answers

List<T> has a nested class called Enumerator .

Thus, the type definition is List<T>.Enumerator (and in your case T is string ).

PS

Actually, List<T>.Enumerator is a struct , not a class , in any case, the type definition will be the same.

In fact, for all nested types, it is always OuterType.NestedType

+8
source

Try this link, there is all the information about List.Enumerator: Enumerator in MSDN documentation

In Essens, an enumerator is used when navigating through the list with each: "Initially, the enumerator is placed before the first element in the collection. At this position, Current is undefined. Therefore, you must call MoveNext to enumerate the enumerator in the first element of the collection before reading the Current value."

+1
source

Source: https://habr.com/ru/post/1342254/


All Articles