作者chhuang (瓶水相逢)
看板C_Sharp
標題Re: [問題] 如何將陣列中重複的值刪掉,只列出不重 …
時間Wed Dec 26 22:55:56 2007
int[] data = {3, 1, 2, 3, 2, 1, 2};
List<int> uniqueList = new List<int>();
{
foreach (int i in data)
{
if (!uniqueList.Contains(i))
{
uniqueList.Add(i);
}
}
}
int[] outputData = uniqueList.ToArray();
Array.Sort(outputData);
--
http://blog.roodo.com/chhuang
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.62.84.89