I have an IEnumerator which has collection of some pictures(Enumarator of PictureCollection object). I want this to appear in random order, means the pictures can appear at random index. Is there any inbuilt C# method to do that or any workaround?
Asked
Active
Viewed 224 times
1 Answers
3
You might need to shuffle the elements of an IEnumerable in a random way.
Random rand = new Random();
var models = garage.OrderBy(c => rand.Next()).Select(c => c.Model).ToList();
Taken from here.
-
1I don't think the select is required. – Reactgular Dec 11 '13 at 22:51
-
Excellent that's what I required. Although I was talking about IEnumerator, not IEnumerable, but I am using a List instead of IEnumerator anyways now. Thanks and yeah I didn't require Select :-) – 0xC0DED00D Dec 11 '13 at 23:14