OP edit: This was a bad question predicated upon a misunderstanding of how yield return
works. The short answer: If you don't want to yield return
something, don't yield return
anything.
There's yield return
to return the next element in the collection and then there's yield break
to end the iteration. Is there a sort of yield continue
to tell the loop controller to skip to the next element?
Here's what I am trying to achieve, though it obviously doesn't build:
static IEnumerable<int> YieldTest()
{
yield return 1;
yield return 2;
yield continue;
yield return 4;
}