System.Collections;
是一个数组链表,具有数组的功能,也有链表的特色。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System; 2 using System.Collections.Generic; 3 public class StudyList1 4 { 5 public static void Main() 6 { 7 List<IWuDang> list = new List<IWuDang>(); 8 list.Add(new People(){Name = "one"}); 9 list.Add(new People(){Name = "two"}); 10 list.Add(new People(){Name = "three"}); 11 list.Add(new People(){Name = "four"}); 12 foreach(IWuDang p in list) 13 { 14 p.GongFu(); 15 } 16 17 18 } 19 } 20 public interface IWuDang 21 { 22 void GongFu(); 23 } 24 public class People:IWuDang 25 { 26 private string name = ""; 27 public string Name 28 { 29 get{return this.name;} 30 set{this.name = value;} 31 } 32 public void print() 33 { 34 Console.WriteLine(this.name); 35 } 36 public void GongFu() 37 { 38 Console.WriteLine("太极"); 39 } 40 }