Order By Random - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IEnumerable

Description

Order By Random

Demo Code


using System.Linq;
using System.Collections.Generic;
using System;/* w ww . jav a  2s . c o  m*/

public class Main{
        public static IEnumerable<T> OrderByRandom<T>(this IEnumerable<T> source)
        {
            var rnd = new Random();
            return source.OrderBy(x => rnd.Next());
        }
}

Related Tutorials