C#中如何去除数组中重复的项

时间:2022-09-02 12:06:07

 

           string[] blogId = arrayhtml.Split(',');//blogId为带有重复项的数组。
            ArrayList result = new ArrayList();
           
            for (int i = 0; i < blogId.Length; i++)
            {
                if (!result.Contains(blogId[i].ToString()))
                    result.Add(blogId[i].ToString());
            }

            foreach (string str in result)
            {
                Console.Write(str + "\n");
            }