除了用于 IEnumerable 之外,yield return 是否有任何用途?

Does yield return have any uses other than for IEnumerable?

C# 的 yield return 是否有 IEnumerables 之外的用途?比如可以不用多线程实现协程吗?

你的问题

Does C#'s yield return have a use outside of IEnumerables

答案是否定的,您可以通过 yield 文档看到这一点

yield (C# Reference)

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 <<<