I have an IEnumerable<object>
which may or may not contain some nested collections. For example, my starting point might look something like this:
[ "foo", 2, [1, 2, 3, 4], "bar" ]
And I want to flatten it to:
[ "foo", 2, 1, 2, 3, 4, "bar" ]
I'm thinking a SelectMany
should work here but can't quite find the right combination. I could brute force it, but I thought there should be a more elegant solution.