C# language feature:
applies to
benefit
- Allows a standard way to traverse of a collection of objects. Facilitate iterator pattern.
how to use
- 1) Include
using System.Collections;
- 2) Implement
IEnumerable
method.
- 3) Create a loop block which returns an iteration value. Precede the
return
statement in the loop with yeild
keyword.
example: