Not. Period. If you are not going to write your own automaton, there is no quick fix for this. See the VB.NET blog post "return return" .
For those who care about what is actually generated (yes, I like the C # precompiler and compiler :)):
Try compiling and take a look at the generated code using .NET Reflector or something:
class Program { static void Main(string[] args) { var foo = new Foo(); foreach(var result in foo.Bar()) { Console.WriteLine(result); } Console.ReadLine(); } } class Foo { public IEnumerable<char> Bar() { const char start = 'a'; for(int x = 0;x < 26;x++) { yield return (char)(start + x); } } }
I am not going to copy the result, it is huge. But look, you will see that this is not easy to solve.
Snake source share