Answers for "c# randomize a list"

C#
6

c# randomize a list

var shuffledcards = cards.OrderBy(a => Guid.NewGuid()).ToList();
Posted by: Guest on August-05-2020
0

c# shuffle

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-26-2020

C# Answers by Framework

Browse Popular Code Answers by Language