删除数组中的重复元素

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = new string[10] { "11", "12", "13", "14", "15", "11", "12", "11", "13", "15" };
            List<string> sList = new List<string>();
            sList.AddRange(s);
            GetNo(0, sList);
        }
        public static  void  GetNo(int index, List<string> numList)
        {
            for (int i = index + 1; i < numList.Count; i++)
            {
                if (numList[index].CompareTo(numList[i]) == 0)
                {
                    numList.RemoveAt(i);
                }
            }

            if (index < numList.Count)
            {
                index++;
                GetNo(index, numList);
            }
            else {
                foreach (string item in numList)
                {
                    Console.WriteLine(item);
                }
            }
          
        }
    }
}

原文地址:https://www.cnblogs.com/guozhe/p/2397957.html