亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C#對多個集合和數(shù)組的操作方法(合并,去重,判斷)

 更新時(shí)間:2016年12月08日 08:47:55   投稿:jingxian  
下面小編就為大家?guī)硪黄狢#對多個集合和數(shù)組的操作方法(合并,去重,判斷)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

在開發(fā)過程中.數(shù)組和集合的處理是最讓我們擔(dān)心.一般會用for or foreach 來處理一些操作.這里介紹一些常用的集合跟數(shù)組的操作函數(shù).

首先舉例2個集合A,B.

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>(); //剔除重復(fù)項(xiàng)

List<int> Result = listA.Concat(listB).ToList<int>(); //保留重復(fù)項(xiàng)

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

在舉例兩個數(shù)組

int[] i=new int[]{1,2};
int[] j=new int[]{2,3};
List<int> r = new List<int>();
r.AddRange(i);

r.AddRange(j);
int[] c = r.ToArray(); 合并數(shù)組

int[] x=i.Union(j).ToArray<int>(); //剔除重復(fù)項(xiàng)

int[] x=i.Concat(j).ToArray<int>(); //保留重復(fù)項(xiàng)

int n = Array.BinarySearch(i,3);//判斷數(shù)組中是否包含某個值.如果包含則返回0

以上這篇C#對多個集合和數(shù)組的操作方法(合并,去重,判斷)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論