I have to make a list containing objects. And the objects need to be in random order. Here I give them random numbers:
Random tal = new Random(); list1[i].nummer = tal.Next(list1.Count); listGold.Add(list1[i]); And now i just need to order them by number. Which I thought linq could do for me. But it can't :S
I am trying this:
RepeaterSponsorGold.DataSource = listGold.OrderBy(n => n.nummer); RepeaterSponsorGold.DataBind(); to order my list by nummer and to put the list into my repater. But the lsit doesn't seem to be sorted... or doesn't seem to get random numbers. i don't know which. Can anybody see what i am doing wrong??
new Random()being created inside the loop that you are using to set the random number? You should onyl create a new Random() once and then use that instance from then on, otherwise you will likely be getting the same random number out repeatedly.nummerfield?