日期:2014-05-17  浏览次数:20956 次

c#去除重复项
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace WindowsFormsApplication130
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Dictionary<string, string> dic = new Dictionary<string, string>();
        string[] str;
        ArrayList array = new ArrayList();
        
        private void Form1_Load(object sender, EventArgs e)
        {
            str = new string[] { "wo", "wo", "ni", "ni", "ta", "ta", "en", "en", "hehe", "shidi", "en" };
        }
        public ArrayList  a()
        {
            for (int i = 0; i < str.Length; i++)
            {
                try
                {
                    dic.Add(str[i], "w");
                    array.Add(str[i]);
                }
                catch
                { }
                finally
                { }
            }
            return array;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string[] s =new string [a ().Count ] ;
            for (int i = 0; i < s.Length; i++)
       &