- 作者:xiaoxiao
- 发表时间:2020-12-23 10:54
- 来源:未知
string allsoftid="8,10,5,44,88,5654,42114,12,10,8,10,54,11,11,10,10,4,45,5,22123,323,200,8,9,65,11,11,664,862,5,545415,21,21,20,3,454,2146,4241,1,2,545,1355"; string[] arrallsoftid=allsoftid.Split(','); NameValueCollection mynv=new NameValueCollection(); int k; for(k=0;k<arrallsoftid.Length;k++) { mynv.Add(arrallsoftid[k],arrallsoftid[k]); } NameValueCollection mynvEND=new NameValueCollection(); string[] temp; for(k=0;k<mynv.Count;k++) { temp=mynv[k].Split(','); mynvEND.Add(temp.Length.ToString(),temp[0]); } for(k=0;k<mynvEND.Count;k++) { Console.WriteLine("出现"+mynvEND.GetKey(k)+"次的有:"+mynvEND[k]); } Console.ReadLine();
执行结果:出现3次的有:8,5出现5次的有:10出现1次的有:44,88,5654,42114,12,54,4,45,22123,323,200,9,65,664,862,545415,20,3,454,2146,4241,1,2,545,1355出现4次的有:11出现2次的有:21