摘要:List練習
class Program
{
static void Main(string[] args)
{
List A = new List()
{
new student {name = "clris",id = 1}, //注意一下寫法
new student {name = "daffy",id = 2}
};
foreach (student tmp in A)
{
Console.WriteLine(tmp.id);
Console.WriteLine(tmp.name);
}
Console.ReadLine();
}
}
public class student
{
public string name { set; get; } //建議寫SET與GET 這樣資料近來還可以篩選
public int id { set; get; } //若不寫就無法去做了
}