对于你的情况,请尽量使用LINQ Concat
:
这导致List<string[]>
var newlist = coords_list
.Concat(outer_plf_list)
.Concat(planet_start_plf_list)
.Concat(planet_plf_list)
或者,如果您需要List<string>
,请执行以下操作:
var newlist = coords_list
.Concat(outer_plf_list)
.Concat(planet_start_plf_list)
.Concat(planet_plf_list)
.SelectMany(x => x)
.ToList();
你也可以使用AddRange
作为一种替代方案:
var newlist = new List<string[]>();
newlist.AddRange(coords_list);
newlist.AddRange(outer_plf_list);
newlist.AddRange(planet_start_plf_list);
newlist.AddRange(planet_plf_list);
如果你有List<List<List<string>>>
而不是List<string[]>
不同string[]
大小,你可以使用SelectMany
拉平List<List<List<string>>>
到List<List<string>>
来源
2016-02-27 15:48:55
Ian
http://stackoverflow.com/questions/4493858/elegant-way-to-combine-multiple-collections-of-elements或http://stackoverflow.com/questions/4734556/concatenate-lists-与-LINQ。 –
@EugenePodskal感谢您的链接。 –
@RyanWalkowski所以,你想要的是一个,单,'列表'是吗?或者它是'List ' –
Ian