I have this IEnumerable :
IEnumerable<MyObject>
and I need to order the list of the MyObject randomly. Do I need to cast into an ArrayList?
Or I can do it directly? Thanks
EDIT
this is my actual random order function :
IList<ArchiePacchettoOfferta> list = new List<ArchiePacchettoOfferta>(m_oEnum);
for (int i = 0; i < list.Count; ++i)
{
HttpContext.Current.Response.Write(list[i].Titolo + "<br />");
}
Random rnd = new Random();
for (int i = 0; i < list.Count; ++i)
{
int swapIndex = rnd.Next(i + 1);
ArchiePacchettoOfferta tmp = list[i];
list[i] = list[swapIndex];
list[swapIndex] = tmp;
}
for (int i = 0; i < list.Count; ++i)
{
HttpContext.Current.Response.Write(list[i].Titolo + "<br />");
}
it orders the list in the same way every time :(