C#中索引器实例
class Name { private string[] names; public int lenth; private int _index; public Name(int lenth) { this._index=0; this.lenth=lenth; names = new string[this.lenth]; } public object this[int index] { set { if (index>=0&&index<this.lenth) { names[index] =(string) value; } } get { if (index>=0&&index<this.lenth) { return names[index]; } return ""; } } }