2

I have a test function that returns an IEnumerable, which inside, I want to yield return other functions that return IEnumerable.

public IEnumerable Foo()
{
    Console.WriteLine("Foo!");
    yield break;
}

public IEnumerable Bar()
{
    Console.WriteLine("Bar!");
    yield break;
}

public IEnumerable Foobar()
{
    foreach (var o in Foo())
    {
        yield return o;
    }

    foreach (var o in Bar())
    {
        yield return o;
    }
}

However, this "Foobar" function will have many more inner functions that return IEnumerable.

Is there any shorter way to do this instead of having to foreach and iterate over very function?

cryptic
  • 21
  • 1

0 Answers0