Answers for "c# random order of list indices"

C#
0

c# get list item in random order

private static Random rng = new Random();  

public static void Shuffle<T>(this IList<T> list)  
{  
    int n = list.Count;  
    while (n > 1) {  
        n--;  
        int k = rng.Next(n + 1);  
        T value = list[k];  
        list[k] = list[n];  
        list[n] = value;  
    }  
}
Posted by: Guest on July-01-2021

C# Answers by Framework

Browse Popular Code Answers by Language