更新时间:2023-02-17 18:16:20
嘿,在下面的表单类中创建people对象
Hey, create people object outside but within the form class like below
Public FormPeople: Window
{
People people = new People();
IList<People> peoples = new List<People>();
Public FormPeople() {
people.dates = new List<Date>();
}
private void btnAddDate_Click_1(object sender, EventArgs e)
{
Date d = new Date();
d.date = dtpDate.Value; //date time picker
people.dates.Add(d); //trying to add the dates into the People list
}
}
private void AddPeople()
{
peoples.add(people);
}
我假设你使用Visual Studio IDE,在项目中你可以声明类。你已经定义了这些类并不重要。
I assumed you use Visual Studio IDEand within the project you can declare classes. It doesn't matter you have already defined those classes.