类:
功能齐全的集合
1using System; 2using System.Collections; 3 4namespace Relaction.Collections 5{ 6 /**//// <summary> 7 /// MyList 的摘要说明。 8 /// </summary> 9 public class MyList:IList 10 { 11 private ArrayList _list; 12 public MyList() 13 { 14 _list = new ArrayList(); 15 } 16 IList 成员#region IList 成员 17 18 public bool IsReadOnly 19 { 20 get 21 { 22 return _list.IsReadOnly; 23 } 24 } 25 26 public object this[int index] 27 { 28 get 29 { 30 return _list[index]; 31 } 32 set 33 { 34 _list[index] = value; 35 } 36 } 37 38 public void RemoveAt(int index) 39 { 40 _list.RemoveAt(index); 41 } 42 43 public void Insert(int index, object value) 44 { 45 _list.Insert(index,value); 46 } 47 48 public void Remove(object value) 49 { 50 _list.Remove(value); 51 } 52 53 public bool Contains(object value) 54 { 55 return _list.Contains(value); 56 } 57 58 public void Clear() 59 { 60 _list.Clear(); 61 } 62 63 public int IndexOf(object value) 64 { 65 return _list.IndexOf(value); 66 } 67 68 public int Add(object value) 69 { 70 return _list.Add(value); 71 } 72 73 public bool IsFixedSize 74 { 75 get 76 { 77 return _list.IsFixedSize; 78 } 79 } 80 81 #endregion 82 83 ICollection 成员#region ICollection 成员 84 85 public bool IsSynchronized 86 { 87 get 88 { 89 return _list.IsSynchronized; 90 } 91 } 92 93 public int Count 94 { 95 get 96 { 97 return _list.Count; 98 } 99 }100101 public void CopyTo(Array array, int index)102 {103 _list.CopyTo(array,index);104 }105106 public object SyncRoot107 {108 get109 {110 return _list.SyncRoot;111 }112 }113114 #endregion115116 IEnumerable 成员#region IEnumerable 成员117118 public IEnumerator GetEnumerator()119 {120 return _list.GetEnumerator();121 }122123 #endregion124 }125}
客户:
客户
1 private void button8_Click(object sender, System.EventArgs e) 2 { 3 Relaction.Collections.MyList list = new Relaction.Collections.MyList(); 4 list.Add(1); 5 list.Add(2); 6 for(int i =0;i<list.Count;i++) 7 { 8 label1.Text += list[i].ToString(); 9 }10 }
转载于:https://www.cnblogs.com/nanshouyong326/archive/2006/11/28/575024.html
相关资源:数据结构—成绩单生成器
转载请注明原文地址: https://win8.8miu.com/read-1481927.html