<p>I could probably write this myself, but the specific way I'm trying to accomplish it is throwing me off.  I'm trying to write a generic extension method similar to the others introduced in .NET 3.5 that will take a nested IEnumerable of IEnumerables (and so on) and flatten it into one IEnumerable.  Anyone have any ideas?</p>

<p>Specifically, I'm having trouble with the syntax of the extension method itself so that I can work on a flattening algorithm.</p>

```
```
static class EnumerableExtensions
{
    public static IEnumerable<T> Flatten<T>(this IEnumerable<IEnumerable<T>> sequence)
    {
        foreach(var child in sequence)
            foreach(var item in child)
                yield return item;
    }
}
```
```
Maybe like this? Or do you mean that it could potentially be infintly deep?