列表与LT; T>串联“X”数量的列表 [英] List<T> Concatenation for 'X' amount of lists

查看:112
本文介绍了列表与LT; T>串联“X”数量的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我列出了所有相同的类型。我可以简单地做:

 列表< T> newset = List1.Concat(List2).Concat(List3).Concat(List4)..... 


.ToList(); 。
也可以调用 newset.AddRange(ListX); 我认为它在表现上更好


I have for example 5 List all of the same type. Can I simply do

List<T> newset = List1.Concat(List2).Concat(List3).Concat(List4).....

解决方案

you can, but do not forget to append .ToList(); in the end. also you can call newset.AddRange(ListX); i think it is better in terms of performance

这篇关于列表与LT; T&GT;串联“X”数量的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆