using System; using System.Collections; using System.Collections.Generic; using System.Linq; // From https://stackoverflow.com/a/2019433/ public static class RandomIEnumerables { public static T PickRandom(this IEnumerable source) { return source.PickRandom(1).Single(); } public static IEnumerable PickRandom(this IEnumerable source, int count) { return source.Shuffle().Take(count); } public static IEnumerable Shuffle(this IEnumerable source) { return source.OrderBy(x => Guid.NewGuid()); } }