Does C#'s yield return
have a use outside of IEnumerables
? For example, could it be used to implement coroutines without the use of multiple threads?
Your question
Does C#'s yield return have a use outside of IEnumerables
The answer is no, you can see this by the yield
documentation
When you use the yield contextual keyword in a statement, you indicate that the method, operator, or get accessor in which it appears is an iterator. Using yield to define an iterator removes the need for an explicit extra class (the class that holds the state for an enumeration, see IEnumerator for an example) when you implement the IEnumerable and IEnumerator pattern for a custom collection type.
Iterator methods and get accessors
The declaration of an iterator must meet the following requirements:
>>>The return type must be IEnumerable, IEnumerable, IEnumerator, or IEnumerator <<<