c#提取数组中不同的元素

int[] a = { 1, 1, 2, 3, 3, 4, 5, 5 };  

  •             List<int> list = new List<int>();  
  •   
  •             foreach (int tmp in a)  
  •             {  
  •                 if (list.Contains(tmp))  
  •                     continue;  
  •                 list.Add(tmp);  
  •             }  
  •             int[] array = list.ToArray();  
  •             for (int i = 0; i < array.Length; i++)  
  •             {  
  •                 Console.Write(array[i].ToString() + " ");  
  •   
  •             }  
  •             Console.Read();  
posted @ 2012-07-11 14:58  Uoolo  阅读(1054)  评论(0编辑  收藏  举报