'How can I avoid IEnumerable nested in another IEnumerable using lambda expressions
I am refactoring some code that currently consists of a foreach inside another foreach to get a list of types. Later on on those types some action is performed.
At the moment I end with an IEnumerable inside another IEnumerable, I wanted to have the final list of types (e.g. IEnumerable or Type[]) to process.
How can I unwind my result, so that I don't have a nested IEnumerable (IEnumerable inside an IEnumerable)?
This is (simplified) my current code:
var types = assemblies.Select(asm => asm.GetExportedTypes()
.Where(t => typeof(IMyCustomValidator).IsAssignableFrom(t) && !t.IsInterface));
This results in types being of type IEnumerable<IEnumerable<Type>>.
I believe there should be a rather simple solution for this issue but I cannot get my head around it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
