I find myself foreach-ing over IEnumerables a lot just so that I can return each result. Is there a way to compress something like this
foreach (var subSelec
With C# 7.0, local functions are allowed, which enables us to have a fairly neat approach
IEnumerable FlatEnumerable(){
IEnumerable> NestedEnumerable(){
yield return myEnumerable1;
yield return myEnumerable2;
}
return NestedEnumerable().SelectMany(e => e);
}
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/local-functions