I have an IEnumerable<IEnumerable<T>>
collection that I want to convert to a single dimension collection. Is it possible to achieve this with a generic extension method? Right now I'm doing this to achieve it.
List<string> filteredCombinations = new List<string>();
//For each collection in the combinated results collection
foreach (var combinatedValues in combinatedResults)
{
List<string> subCombinations = new List<string>();
//For each value in the combination collection
foreach (var value in combinatedValues)
{
if (value > 0)
{
subCombinations.Add(value.ToString());
}
}
if (subCombinations.Count > 0)
{
filteredCombinations.Add(String.Join(",",subCombinations.ToArray()));
}
}
If it's not possible to get a generic solution, how can I optimize this in an elegant fashioned way.