实现Ilist接口的类

类:
ContractedBlock.gif ExpandedBlockStart.gif 功能齐全的集合
  1None.gifusing System;
  2None.gifusing System.Collections;
  3None.gif
  4None.gifnamespace Relaction.Collections
  5ExpandedBlockStart.gifContractedBlock.gifdot.gif{
  6ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
  7InBlock.gif    /// MyList 的摘要说明。
  8ExpandedSubBlockEnd.gif    /// </summary>

  9InBlock.gif    public class MyList:IList
 10ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 11InBlock.gif        private ArrayList _list;
 12InBlock.gif        public MyList()
 13ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 14InBlock.gif            _list = new ArrayList();
 15ExpandedSubBlockEnd.gif        }

 16ContractedSubBlock.gifExpandedSubBlockStart.gif        IList 成员#region IList 成员
 17InBlock.gif
 18InBlock.gif        public bool IsReadOnly
 19ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 20InBlock.gif            get
 21ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 22InBlock.gif                return _list.IsReadOnly;
 23ExpandedSubBlockEnd.gif            }

 24ExpandedSubBlockEnd.gif        }

 25InBlock.gif
 26InBlock.gif        public object this[int index]
 27ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 28InBlock.gif            get
 29ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 30InBlock.gif                return _list[index];
 31ExpandedSubBlockEnd.gif            }

 32InBlock.gif            set
 33ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 34InBlock.gif                _list[index] = value;
 35ExpandedSubBlockEnd.gif            }

 36ExpandedSubBlockEnd.gif        }

 37InBlock.gif
 38InBlock.gif        public void RemoveAt(int index)
 39ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 40InBlock.gif            _list.RemoveAt(index);
 41ExpandedSubBlockEnd.gif        }

 42InBlock.gif
 43InBlock.gif        public void Insert(int index, object value)
 44ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 45InBlock.gif            _list.Insert(index,value);
 46ExpandedSubBlockEnd.gif        }

 47InBlock.gif
 48InBlock.gif        public void Remove(object value)
 49ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 50InBlock.gif            _list.Remove(value);
 51ExpandedSubBlockEnd.gif        }

 52InBlock.gif
 53InBlock.gif        public bool Contains(object value)
 54ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 55InBlock.gif            return _list.Contains(value);
 56ExpandedSubBlockEnd.gif        }

 57InBlock.gif
 58InBlock.gif        public void Clear()
 59ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 60InBlock.gif            _list.Clear();
 61ExpandedSubBlockEnd.gif        }

 62InBlock.gif
 63InBlock.gif        public int IndexOf(object value)
 64ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 65InBlock.gif            return _list.IndexOf(value);
 66ExpandedSubBlockEnd.gif        }

 67InBlock.gif
 68InBlock.gif        public int Add(object value)
 69ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 70InBlock.gif            return _list.Add(value);
 71ExpandedSubBlockEnd.gif        }

 72InBlock.gif
 73InBlock.gif        public bool IsFixedSize
 74ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 75InBlock.gif            get
 76ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 77InBlock.gif                return _list.IsFixedSize;
 78ExpandedSubBlockEnd.gif            }

 79ExpandedSubBlockEnd.gif        }

 80InBlock.gif
 81ExpandedSubBlockEnd.gif        #endregion

 82InBlock.gif
 83ContractedSubBlock.gifExpandedSubBlockStart.gif        ICollection 成员#region ICollection 成员
 84InBlock.gif
 85InBlock.gif        public bool IsSynchronized
 86ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 87InBlock.gif            get
 88ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 89InBlock.gif                return _list.IsSynchronized;
 90ExpandedSubBlockEnd.gif            }

 91ExpandedSubBlockEnd.gif        }

 92InBlock.gif
 93InBlock.gif        public int Count
 94ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 95InBlock.gif            get
 96ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 97InBlock.gif                return _list.Count;
 98ExpandedSubBlockEnd.gif            }

 99ExpandedSubBlockEnd.gif        }

100InBlock.gif
101InBlock.gif        public void CopyTo(Array array, int index)
102ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
103InBlock.gif            _list.CopyTo(array,index);
104ExpandedSubBlockEnd.gif        }

105InBlock.gif
106InBlock.gif        public object SyncRoot
107ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
108InBlock.gif            get
109ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
110InBlock.gif                return _list.SyncRoot;
111ExpandedSubBlockEnd.gif            }

112ExpandedSubBlockEnd.gif        }

113InBlock.gif
114ExpandedSubBlockEnd.gif        #endregion

115InBlock.gif
116ContractedSubBlock.gifExpandedSubBlockStart.gif        IEnumerable 成员#region IEnumerable 成员
117InBlock.gif
118InBlock.gif        public IEnumerator GetEnumerator()
119ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
120InBlock.gif            return _list.GetEnumerator();
121ExpandedSubBlockEnd.gif        }

122InBlock.gif
123ExpandedSubBlockEnd.gif        #endregion

124ExpandedSubBlockEnd.gif    }

125ExpandedBlockEnd.gif}

客户:
ContractedBlock.gif ExpandedBlockStart.gif 客户
 1None.gif    private void button8_Click(object sender, System.EventArgs e)
 2ExpandedBlockStart.gifContractedBlock.gif        dot.gif{
 3InBlock.gif            Relaction.Collections.MyList list = new Relaction.Collections.MyList();
 4InBlock.gif            list.Add(1);
 5InBlock.gif            list.Add(2);
 6InBlock.gif            for(int i =0;i<list.Count;i++)
 7ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 8InBlock.gif                label1.Text += list[i].ToString();
 9ExpandedSubBlockEnd.gif            }

10ExpandedBlockEnd.gif        }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值