Building a Named Iterator
It is also interesting to note that the yield keyword can technically be used within any method,
regardless of its name. These methods (which are technically called
named iterators) are also
unique in that they can take any number of arguments. When building a named iterator, be very
aware that the method will return the IEnumerable interface, rather than the expected IEnumerator-
compatible type. To illustrate, we could add the following method to the Garage type:
public IEnumerable GetTheCars(bool ReturnRevesed)
{
Do'stlaringiz bilan baham: |