2
I have the following object:
public class Object{
public String ID{get;set;}
}
And in a moment in my code I get a list of them:
List<Object> objs = new List<Object>();
objs.add(new Object{ID = "1"});
objs.add(new Object{ID = "2"});
objs.add(new Object{ID = "3"});
objs.add(new Object{ID = "4"});
And then I randomize the objects:
objs = objs.OrderBy(a => Guid.NewGuid()).ToList();
Debug.WriteLine(objs.ID);
// 1 4 2 3
If I run objs.OrderBy(a => Guid.NewGuid()).ToList();
I’ll get a totally random order // 3 2 4 1
.
I need to pass a "Seed" (an integer) and randomize relative to it, for example, if I pass the number 1 and receive // 3 2 4 1
, when I run number 1 again I need to receive the same order.
Is there a resource in c# to do this?