using System;
using System.Collections.Generic;
namespace ConsoleApplication_C_Sharp
{
public static class SF
{
public static void Shuffle<T>(this IList<T> list)
{
int count = list.Count;
Random rnd = new Random();
while (count > 1) {
int k = (rnd.Next(0, count) % count);
count--;
T value = list[k];
list[k] = list[count];
list[count] = value;
}
}
}
class Program
{
static void Main(string[] args)
{
List<int> list = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
SF.Shuffle(list);
Console.WriteLine(String.Join(" ", list));
}
}
}
/*
run:
8 7 3 1 4 6 5 2 9
*/