N-Ary/Multiple-List Cartesian Product
问题 in Product SKUs, we can get Cartesian Product in the way of LINQ: string[] arr1 = new[] {"red", "blue", "orange"}; string[] arr2 = new[] {"5 inche", "8 inch"}; var result = from a in arr1 from b in arr2 select a + " " + b; foreach (var item in result){ Console.WriteLine(item); } We know the exact number of arrays. My question is: If the number of arrays is dynamic, how do we get Cartesian Product? Thanks. 回答1: I'd put them in a list of string arrays. Then I'd use ForEach : IEnumerable<string>