Created
December 30, 2015 07:20
-
-
Save goshki/69f3ee4e52d65a8af241 to your computer and use it in GitHub Desktop.
A helper method to easily randomize the order of elements in a given list using LINQ.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
public class LinqListShuffler { | |
public List<string> Shuffle(List<string> list) { | |
Random random = new Random(); | |
return list.OrderBy(x => random.Next()).ToList(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment