日期:2014-05-18 浏览次数:21007 次
string strOld = "aaaaaa\r\nbbbbbb\r\ncccccc\r\ndddddd\r\neeeeee\r\nffffff\r\n"; string[] strTemp = strOld.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); ArrayList alNew = new ArrayList(); Random r = new Random(); while (true) { int i = r.Next(0, strTemp.Length); if (!alNew.Contains(strTemp[i])) alNew.Add(strTemp[i]); if (alNew.Count == strTemp.Length) break; } foreach (object obj in alNew) { Console.WriteLine(obj); }