This question already has an answer here:
I have tried to generate a list of random DateTime objects, i need them to create some kind of schedule. If I debug the code and do it step by step I get random dates but if I simply run the app I only get the same date multiple times.
This is my code to generate random date:
public Exam() { var random = new Random(); var year = random.Next(2014, 2015); var month = random.Next(1, 12); var day = random.Next(1, 30); Date = new DateTime(year, month, day); }
and when I create the list of Exams:
for (var i = 0; i < exams; i++) { ExamList.Add(new Exam()); }
Aucun commentaire:
Enregistrer un commentaire