[Solved] How to change loop of nested lists linq
Avoiding the foreach will lose a small amount of performance and make the code harder to follow, but based on your (probably wrong) question, here is the equivalent LINQ: var ans = listL1.elements.SelectMany(level1 => level1.elements.SelectMany(level2 => listL2.elements.Select(level3 => new Level() { itemFromLevel1 = level1, itemFromLevel2 = level2, itemFromLevel3 = level3}))).ToList(); 2 solved How to change … Read more