c# 集合的合并举例

eg:

List<string> listA = new List<string> {"1","2","3"};
List<string> listB = new List<string> {"2","4","17"};
 
List<string> Result = listA.Union(listB).ToList<string>();    //剔除重复项 List<string> {"1","2","3","4","17"};
List<string> Result = listA.Concat(listB).ToList<string>();  //保留重复项 List<string> {"1","2","3","2","4","17"};

listA.BinarySearch("1");//判断集合中是否包含某个值.如果包含则返回0
int[]
int n = Array.BinarySearch(i,3);//判断数组中是否包含某个值.如果包含则返回0

 

posted @ 2019-12-02 10:47  芮源  阅读(920)  评论(0编辑  收藏  举报