所以,基本上我需要用数组而不是手动填充这个当前列表:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
List<People> people = new List<People>()
{
new People{Name="John",Age=21,Email="john@abc.com"}
new People{Name="Tom",Age=30,Email="tom@abc.com"}
};
}
}
到目前为止,我有这样的人:
class People
{
public string Name { get; set; }
public int Age { get; set; }
public string Email { get; set; }
}
我想改用数组,从 People 类到 MainWindow 类。就像是:
class People
{
public string[] Name =
{
"John",
"Tom",
};
public int[] Age =
{
"21",
"30",
}
...
}
我似乎无法弄清楚如何使用这些数组来填充这个列表。提前感谢您的宝贵时间。