//Concat()方法附加两个相同类型的序列,并返回一个新序列(集合) IListstrList = new List () { "One", "Two", "Three", "Four", "Five" };IList str1List = new List () { "One", "Two", "Three", "Four", "Five" };IEnumerable 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(); list.AddRange(strList); list.AddRange(str1List);
哎,悲哀!
Union 和 Concat 不一样的地方是它要去重