Witam, mój problem prezentuje się następująco: chcę stworzyć listę złożoną z obiektów klasy "Patient", która wygląda tak:
class Patient
{
public Patient(int age, string name, string surname)
{
Age = age;
Name = name;
Surname = surname;
}
public string Name { get; set; }
public string Surname { get; set; }
public int Age { get; set; }
}
Listę chcę stworzyć w ten sposób:
static void Main(string[] args)
{
List<Patient> PatientList = new List<Patient>();
Random rnd = new Random();
for (int i = 0; i < 25; i++)
{
PatientList.Add(new Patient(rnd.Next(13,81), Generator.CreateName(), Generator.CreateSurname() ));
}
}
W klasie Generator posiadam dwie metody statyczne. Problem polega na tym, że mimo tego, że po uruchomieniu programu wszyscy pacjenci nazywają się zawsze tak samo. Innymi słowy metody losują imiona i nazwiska tylko raz podczas uruchamiania.
Co jest tego przyczyną? Jak sprawić, żeby podczas dodawania kolejnego pacjenta w pętli, metody
CreateName()
i CreateSurname()
zwracały różne wartości?