我有以下课程;
abstract class People
{
string name;
bool disabled;
string hometown;
Hometown referenceToHometown;
// default constructor
public People()
{
name = "";
disabled = false;
hometown = "";
}
我想向其中添加数据,以便稍后在表单上显示 - 经过研究,我有了这个,但出现了一些错误“无效令牌'='”
namespace peoplePlaces
{
public partial class frm_people : Form
{
List<People> people = new List<People>();
People data = new ();
data.name = "James";
data.disabled = false;
data.hometown = "Cardiff"
people.Add(data);
}
}
这是向类添加数据的更简洁的方法吗?这样做是否可以制作一个表格来循环记录?
任何帮助将不胜感激!