string[] arr_a = { "1", "2", "3" }; string[] arr_b = { "5" }; string[] arr_c = { "6", "7" }; var q = from a1 in arr_a from b1 in arr_b from c1 in arr_c select a1 + b1 + c1; foreach (var item in q) { Console.WriteLine(item); } string[] arr_d = { "9", "10" }; List<string[]> ls = new List<string[]>(); ls.Add(arr_a); ls.Add(arr_b); ls.Add(arr_c); ls.Add(arr_d); var qx = from a1 in ls.ToArray() from xx in a1 select xx; foreach (var item in qx) { Console.WriteLine(item); }
动态LIST怎么LING”输出上面一样的数据?
解决方案
20
var qx = ls[0].ToList(); for (var i = 1; i < ls.Count; i++) qx = (from a in qx from b in ls[i].ToList() select a + b).ToList();
20
不转 List 也行
var qx = ls[0]; for (var i = 1; i < ls.Count; i++) qx = (from a in qx from b in ls[i] select a + b).ToArray();