Treat multiple IEnumerable objects as a single IEnumerable
- by MainMa
Hi,
My question seems to be something easy, but I can't figure it out.
Let's say I have a "root" IEnumerable of objects. Each object has IEnumerable of strings. How can I obtain a single IEnumerable of those strings?
A possible solution is to do:
public IEnumerable<string> DoExample()
{
foreach (var c in rootSetOfObjects)
{
foreach (var n in c.childSetOfStrings)
{
yield return n;
}
}
}
But maybe there is a magic solution with Linq?