...
So, to wrap up our look at building enumerable objects, remember that in order for your
custom types to work with the C# foreach keyword, the container must define a method named
GetEnumerator(), which has been formalized by the IEnumerable interface type. The implementa-
tion of this method is typically achieved by simply delegating it to the internal member that is
holding onto the subobjects; however, it is also possible to make use of the yield return syntax to
provide multiple “named iterator” methods.
Do'stlaringiz bilan baham: