简单的说就和数组引用很类似如:集合 set[索引]就这么简单

解决方案 »

  1.   

    例如:
      public int this [int index]   // indexer declaration
       {
          get 
          {
             // Check the index limits
             if (index < 0 || index >= 100)
                return 0;
             else
                return myArray[index];
          }
          set 
          {
             if (!(index < 0 || index >= 100))
                myArray[index] = value;
          }
       }
      

  2.   

    http://www.ccidnet.com/tech/guide/2001/06/08/58_2306.html
      

  3.   

    当我们访问类中一个集合时,希望类本身就像一个数组,因为除了这个集合外可能还有很多成员性质和方法。所以我们可以建立一个索引来访问,这样方便。
        索引器是一种特殊的性质,包括get()和set()方法。其语法如何申明我就不再说了,大家都知道。关键是建立索引有何用处,先举个例子:
      public class ListIndexer
     {
        public ListIndexer(params string[] Strings)
       {
         //此处为处理字符串代码
       }
       .....
       .....
       public int this[int index]   
       {
          get 
          {
             if (index < 0 || index >= 100)
                return 0;
             else
                return myArray[index];
          }
          set 
          {
             if (!(index < 0 || index >= 100))
                myArray[index] = value;
          }
        }
       .....
       .....
     }
      

  4.   

    它就好像一个数组,是一种C#的语法构造,可以用我们熟悉的数组方括号语法访问类中的集合.索引器是一种特殊的性质,含有规定其行为的get()和set()方法.
    可以用如下语法声明类中的索引器性质:类型 this[类型 参数]{get;set}例如:string mystring = arreylist [0];
      

  5.   

    类似于c++里面的[]重载
    可以把array象数组一样引用