C# yield in nested method
Posted
by Fastidious
on Stack Overflow
See other posts from Stack Overflow
or by Fastidious
Published on 2010-03-23T23:20:24Z
Indexed on
2010/03/23
23:23 UTC
Read the original article
Hit count: 634
If I step through the following code the call to ReturnOne() is skipped.
static IEnumerable<int> OneThroughFive()
{
ReturnOne();
yield return 2;
yield return 3;
yield return 4;
yield return 5;
}
static IEnumerator<int> ReturnOne()
{
yield return 1;
}
I can only assume that the compiler is stripping it out because what I'm doing is not valid. I'd like the ability to isolate my enumeration into various methods. Is this possible?
© Stack Overflow or respective owner