//工具类
private static Random random = new Random();
public static void Shuffle<T>(this IList<T> arr)
{
var n = arr.Count();
while (n > 1)
{
n--;
var k = random.Next(0, n + 1);
var val = arr[k];
arr[k] = arr[n];
rr[n] = val;
}
}
//使用:
List<string> tmpList = new List<string>();
tmpList.Shuffle()
标签:arr,C#,打乱,random,tmpList,var,static,集合
From: https://www.cnblogs.com/Licy113/p/17671490.html