I have a list of images that I want randomized but what i'm using (order by new guid first) isn't working. I tried this...
var testA = item.Images.ToList().OrderBy(x => new Guid()).First();
var testB = item.Images.ToList().OrderBy(x => new Guid()).First();
var testC = item.Images.ToList().OrderBy(x => new Guid()).First();
... but they are all getting the same image. This code is in the controller action for the user control that displays the image. What am I doing wrong?
Jennica
Member
500 Points
341 Posts
Random item from list not working
Apr 16, 2012 11:38 AM|LINK
Hey,
I have a list of images that I want randomized but what i'm using (order by new guid first) isn't working. I tried this...
... but they are all getting the same image. This code is in the controller action for the user control that displays the image. What am I doing wrong?
Prashant Kum...
Star
12528 Points
2024 Posts
Re: Random item from list not working
Apr 16, 2012 11:57 AM|LINK
The code should be