c#对一个数组进行打乱顺序

不用在为有没标记这个数据是不是已经被添加过了,这个已经随机生成过了 下次又出现了 怎么办 而烦恼了
public  Hashtable  NoOrder(int count)
        {
            ArrayList mylist = new ArrayList();
            Hashtable hash = new Hashtable();
            Random r=new Random ();
            for (int i = 0; i < count; i++)
            {
                mylist.Add(i);
            }
            int listcount=mylist.Count;
            for (int i = 0; i < listcount; i++)
            {
               int rand= r.Next(mylist.Count);
               hash.Add(mylist[rand],i );
               mylist.RemoveAt(rand);
            }
            return hash;
        }  
posted @ 2011-01-17 19:08  三月软件工作室——任忌  阅读(5109)  评论(0编辑  收藏  举报