posts - 7, comments - 29, trackbacks - 0, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

公告

字符串数组去掉重复值方法

Posted on 2008-12-14 20:02 艾新 阅读(388) 评论(1) 编辑 收藏

using System;
using System.Collections;
using System.Collections.Specialized;
namespace test
{
    class myTest
    {
        static void Main()
        {

            string[] arrInt = new string[] { "1", "1", "2", "3", "4", "33", "4", "66", "77", "2", "44", "33" };
            ArrayList arr = new ArrayList();
            foreach (string i in arrInt)
            {
                if (arr.IndexOf(i) < 0)
                {
                    arr.Add(i);
                   
                }
            }

            //输出测试  
            arrInt = (string[])arr.ToArray(typeof(string));
            foreach (string n in arrInt)
            {
                Console.WriteLine(n);
            }  
        }
    }
}