我的错误在我的 for 语句中,语法错误是说我的构造函数没有接受三个参数。
string[] first = new string[20] { "Scott", "Ramona", "Todd", "Melissa", "Naomi", "Leland", "Conor", "Julie", "Armondo", "Leah",
"Frank", "Peter", "Ila", "Mandy", "Sammy", "Gareth", "Garth", "Wayne", "Freddy", "Mark" };
string[] last = new string[20] { "Kennedy", "Kennedy", "Kennedy", "Kennedy", "Kennedy", "Kennedy", "Carrel", "MaloyTheBeautiful", "Johnson", "Smith",
"Sinatra", "Clemens", "Eels", "Johnson", "Eels", "Thompson", "Brooks", "World", "Crugar", "Thomas" };
DateTime[] birth = new DateTime[20];
birth[0] = new DateTime(1987, 22, 7);
birth[1] = new DateTime(1962, 15, 9);
birth[2] = new DateTime(1984, 21, 4);
birth[3] = new DateTime(1977, 24, 1);
birth[4] = new DateTime(1983, 12, 8);
birth[5] = new DateTime(1979, 14, 1);
birth[6] = new DateTime(1965, 19, 9);
birth[7] = new DateTime(1968, 21, 2);
birth[8] = new DateTime(1980, 22, 7);
birth[9] = new DateTime(1982, 20, 7);
birth[10] = new DateTime(1984, 19, 4);
birth[11] = new DateTime(1968, 11, 9);
birth[12] = new DateTime(1968, 21, 8);
birth[13] = new DateTime(1975, 5, 2);
birth[14] = new DateTime(1945, 15, 3);
birth[15] = new DateTime(1969, 14, 6);
birth[16] = new DateTime(1987, 141, 4);
birth[17] = new DateTime(1976, 23, 5);
birth[18] = new DateTime(1989, 28, 6);
birth[19] = new DateTime(1988, 23, 9);
// Populate Array Person[] People = new Person[20];
for (int i = 0; i < People.Length; i++)
{
People[i]= new Person(first[i], last[i], birth[i]);
}
我的班级看起来像这样
public class Person
{
private string _firstname;
private string _lastname;
private DateTime _birthDate;
public void Personn(string firstname, string lastname, DateTime birthDate)
{
_firstname = firstname;
_lastname = lastname;
_birthDate = birthDate;
}
public string Firstname
{ get { return _firstname; } }
public string Lastname
{ get { return _lastname; } }
public DateTime Birthdate
{ get { return _birthDate; } }
}