I almost know its impossible and meaningless, but just trying to learn.. I have:
public IEnumerable<IEnumerable<object>> GetMany()
{
while (someCondition)
yield return GetFew();
}
static IEnumerable<object> GetFew()
{
while (someOtherCondition)
yield return new object();
}
Can I combine the two and form one method? Can two different iterator blocks lie in one method?
Edit: I am not asking how to solve the problem I have at hand. I'm trying to learn something new, so the larger question is "there a way two separate blocks can be made to work in one function"? I ask because there are anonymous types and closure in C# where you can have something new defined inside a method itself without a named type or method. Likewise for blocks?