C# List<T> 合并、去重、查找

 List<int> listA = new List<int> {1,2,3,5,7,9};
 List<int> listB = new List<int> {13,4,17,29,2};

 
 listA.AddRange(listB );//把集合A.B合并
 List<int> Result = listA.Union(listB).ToList<int>();          //剔除重复项 
 List<int> Result = listA.Concat(listB).ToList<int>();        //保留重复项

 listA.BinarySearch("1");//判断集合中是否包含某个值.如果包含则返回0

 

posted @ 2017-01-03 15:40  微笑代表淡定.Net  阅读(12591)  评论(0编辑  收藏  举报