1 class Master 2 { 3 publicintId{ get;set;} 4 publicstringName{ get;set;} 5 publicintAge{ get;set;} 6 publicstringKongfu{ get;set;} 7 publicstringMenPai{ get;set;} 8 publicintLevel{ get;set;} 9 public overide string ToString()10 {11 return string.Fromat("Id:{0},Name:{1},Age:{2},Kongfu:{3},MenPai:{4},Level:{5}", Id, Name, Age, Kongfu, Menpai, Leve)12 }13 }
1 class KongFu 2 { 3 public int Id { get;set;} 4 public string Name { get;set;} 5 public int Power { get;set;} 6 7 public override string ToString() 8 { 9 return string.Format("Id:{0},Name:{1},Power:{2}", Id, Name, Power);10 }11 }
1 static void Main (String [] args) 2 {3 var master = newList <Master> () 4 {5 newMaster () {Id = 1, Name = "Huang Rong ", age = 18, Menpai = "", Kongfu = "" ", Level = 9}, 6 newMaster () {Id = 2, Name =" ", age = 70, Menpai = "", Kongfu = "" ", Level = 10}, 7 newMaster () {Id = 3, Name =" Guo Jing ", age = 22, Menpai = "", Kongfu = "", Level = 10}, 8 newMaster () {Id = 4, Name = "", age = 50, Menpai = "Mingjiao", Kongfu = "sunflower Collection", Level = 1}, 9 newMaster () {Id = 5, Name = "Invincible ", age = 35, Menpai = "Mingjiao", Kongfu = "sunflower Collection", Level = 10}, 10 newMaster () {Id = 6, Name = "Lin pingzhi ", age = 23, Menpai = "Huashan", Kongfu = "sunflower Collection", Level = 7}, 11 newMaster () {Id = 7, Name = "Yue Bu ", age = 50, Menpai = "Huashan", Kongfu = "sunflower Collection", Level = 8}, 12 newMaster () {Id = 8, Name = "Ling huchong ", age = 23, Menpai = "Huashan", Kongfu = "Gu JIU Jian", Level = 10}, 13 newMaster () {Id = 9, Name = "Mei chaofeng ", age = 23, Menpai = "Plum Blossom Island", Kongfu = "jiuyin Zhenjing", Level = 10}, 14 newMaster () {Id = 10, Name = "Yellow pharmacist", Age = 23, menpai = "Plum Blossom Island", Kongfu = "", Level = 10}, 15 newMaster () {Id = 11, Name = "", Age = 23, menpai = "Huashan", Kongfu = "lone nine swords", Level = 10} 16}; 17 var kongfu = newList <KongFu> () 18 {19 newKongFu () {Id = 1, Name = "dongles", Power = 95}, 20 newKongFu () {Id = 2, Name = "", Power = 100 }, 21 newKongFu () {Id = 3, Name = "", Power = 100}, 22 newKongFu () {Id = 4, Name =" ", power = 100}, 23 newKongFu () {Id = 5, Name = "jiuyin Zhenjing", Power = 100}, 24 newKongFu () {Id = 6, name = "Power = 100}, 25}; 26}