How to write sub-methods returning IResult

Oct 1, 2010 at 11:49 PM

Hello,
I run into strange issue.

Frequently I need in coroutine method (returning IEnumerable<IResult>) call another coroutine method (returning another IEnumerable<IResult>).

I solve it like this

 

public IEnumerable<IResult> RoutineOne()
{
            yield return Coroutines.CallWs(..);
..
            yield return Coroutines.CallWs(..);
..
}

public IEnumerable<IResult> RoutineTwo()
{
            yield return Coroutines.OpenFileDialog(dialog);
..
            //yield return RoutineOne(); //It would be great, but don't work

           var results = RoutineOne(); //This my ugly graceless solution, not realy simple and readable
           foreach (var result in results)
           {
                yield return result;
           }
..
}

Have anyone found better alternative.

Clearest solution seems to me is add to C# keyword "yield many return" :-)

Coordinator
Oct 2, 2010 at 3:54 AM

The foreach is really the only way I know of.