Today I was doing some LINQ to objects. I was replacing a pair of nested foreach loops which built a string list and was looking for an elegant way to do it in LINQ. I ran into the problem that I needed to convert a list of lists to a single list. The following extension method works great for that. Works great for merging arrays of arrays without copying anything.
public static class ExtensionMethods
{
public static IEnumerable<T> UnionAll<T>(this IEnumerable<IEnumerable<T>> eet)
{
foreach (var et in eet)
foreach (var t in et)
yield return t;
}
}