//Concat()方法附加两个相同类型的序列,并返回一个新序列(集合)
IList<string> strList = new List<string>() { "One", "Two", "Three", "Four", "Five" }; IList<string> str1List = new List<string>() { "One", "Two", "Three", "Four", "Five" }; IEnumerable<string> newlist = strList.Concat(str1List); newlist.ToList().ForEach(f => Console.Write(f + ","));
//显示结果为:  One,Two,Three,Four,Five,One,Two,Three,Four,Five,

 

原来还有这种写法,自己还记了笔记的.悲哀!

一直以来,我都是这样写的:

                var list = new List<string>();
                list.AddRange(strList);
                list.AddRange(str1List);

哎,悲哀!

 

Union 和 Concat 不一样的地方是它要去重

相关文章:

  • 2022-12-23
  • 2021-09-21
  • 2021-07-12
  • 2022-12-23
  • 2021-08-07
  • 2022-01-27
  • 2022-12-23
  • 2021-05-21
猜你喜欢
  • 2021-09-25
  • 2021-10-10
  • 2022-12-23
  • 2022-03-03
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案