Treat multiple IEnumerable objects as a single IEnumerable
Posted
by MainMa
on Stack Overflow
See other posts from Stack Overflow
or by MainMa
Published on 2010-06-12T00:56:42Z
Indexed on
2010/06/12
1:02 UTC
Read the original article
Hit count: 304
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?
© Stack Overflow or respective owner