one line shuffling IEnumarable
actually two
public static IEnumerableShuffle (this IEnumerable source)
{
Random rand=new Random(DateTime.Now.Ticks);
return source.Select(t => new Pair(rand.Next(), t)).OrderBy(pair => (int)pair.First)
.Select(pair => (T)pair.Second).ToList();
{
אין תגובות:
הוסף רשומת תגובה