文章出處

 public static void Purge(ref List<string> needToPurge)
        {

            for (int i = 0; i < needToPurge.Count - 1; i++)
            {
                string deststring = needToPurge[i];
                for (int j = i + 1; j < needToPurge.Count; j++)
                {
                    if (deststring.CompareTo(needToPurge[j]) == 0)
                    {
                        needToPurge.RemoveAt(j);
                        j--;
                        continue;
                    }
                }
            }
        }

使用:

  List<string> list = new List<string>();
            list.Add("1");
            list.Add("1");
            list.Add("2");
            list.Add("1");
            list.Add("3");
            list.Add("3");
            Purge(ref list);

//輸出:

//1 、2、3


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()