use indexer, something like
public object this [int index] 
{
  get {...}
  set {...}
}see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfindexedpropertiespg.asp

解决方案 »

  1.   

    get 
    {
       return myArray[index];
    }
    set 
    {
       myArray[index] = value;
    }
      

  2.   

    要继承一些接口,如下是个例子:using System;
    using System.Collections;
    namespace Fetri.oilManageClass
    {
        public class SysnoteEntityCollection:IList,ICollection,IEnumerable
        {
            System.Collections.ArrayList elements;
            public SysnoteEntityCollection()
            {
                elements=new System.Collections.ArrayList();
            }        public SysnoteEntity this[int index]
            {
                get
                {
                    return (SysnoteEntity)this.elements[index];
                }
                set
                {
                    this.elements[index]=value;
                }
            }        int IList.IndexOf(object value)
            {
                return ((SysnoteEntityCollection)this).IndexOf((SysnoteEntity)value);
            }        public int IndexOf(SysnoteEntity value)
            {
                return this.elements.IndexOf(value);
            }        public bool IsReadOnly
            {
                get
                {
                    return this.elements.IsReadOnly;
                }
            }        object IList.this[int index]
            {
                get
                {
                    return ((SysnoteEntityCollection)this)[index];
                }
                set
                {
                    ((SysnoteEntityCollection)this)[index]=(SysnoteEntity)value;
                }
            }        public bool IsFixedSize
            {
                get
                {
                    return this.elements.IsSynchronized;
                }
            }        public bool IsSynchronized
            {
                get
                {
                    return true;
                }
            }        public int Count
            {
                get
                {
                    return this.elements.Count;
                }
            }        public void CopyTo(System.Array array,int index)
            {
                this.elements.CopyTo(array,index);
            }        public object SyncRoot
            {
                get
                {
                    return this.elements.SyncRoot;
                }
            }        public System.Collections.IEnumerator GetEnumerator()
            {
                return this.elements.GetEnumerator();
            }        public int Add(SysnoteEntity value)
            {
                return this.elements.Add(value);
            }        int IList.Add(object value)
            {
                return ((SysnoteEntityCollection)this).Add((SysnoteEntity)value);
            }        void IList.Insert(int index, object value)
            {
                ((SysnoteEntityCollection)this).Insert(index,(SysnoteEntity)value);
            }        public void Insert(int index, SysnoteEntity value)
            {
                this.elements.Insert(index,value);
            }        public void RemoveAt(int index)
            {
                this.elements.RemoveAt(index);
            }        void IList.Remove(object value)
            {
                ((SysnoteEntityCollection)this).Remove((SysnoteEntity)value);
            }        public void Remove(SysnoteEntity value)
            {
                this.elements.Remove(value);
            }        bool IList.Contains(object value)
            {
                return ((SysnoteEntityCollection)this).Contains((SysnoteEntity)value);
            }        public bool Contains(SysnoteEntity value)
            {
                return this.elements.Contains(value);
            }        public void Clear()
            {
                this.elements.Clear();
            }
        }
    }
      

  3.   

    this [int index] 
    索引
      

  4.   

    用索引器就可以了不用那么麻烦去实现那些接口把!!
    例如:1: 定义类
    class MyArray
    {
    ArrayList list = new ArrayList();
    .....  public object this[int index]
      {
          get{return this.list[index];}
          set{this.list[index] = value;}
      }
    .....
    }2: 运用MyArray _arrayObj = new MyArray();
    object obj = _arrayObj[2];
      

  5.   

    index不行,因为如果这样a[i]就作不了引用参数了
    要重载[]