interface IMyExample { 
 string this[int index] { get ; set ; } 
 event EventHandler Even ; 
 void Find(int value) ; 
 string Point { get ; set ; } 

这个接口里面的这句话this[int index] 作何解释呢?

解决方案 »

  1.   

    对象本身的枚举属性
     
    比如 column a = table.columns[5];
      

  2.   

    索引器可以使对象能用下标来得到一个值。定义索引器为类创建了”虚拟数组”,该类的实例可以使用[]数组访问运算符进行访问,再直白点说,看起来访问的是对象数组,其实访问的是对象中的一个数组,实现了对对象内部成员一定的封装using System;class Team
    {
    string [] name = new string[8]; public string this[int i]
    {
    get {return name[i];}
    set {name[i] = value;}
    }
    }class Test
    {
    static void Main(string[] args)
    {
    Team t = new Team();
    for(int i = 0; i < 8; i++)
    //只有一个对象t,为什么能访问t[i]呢,因为其实访问的t对象内的name数组
    t[i] = "value" + i;
    for(int i = 0; i < 8; i++)
    Console.WriteLine(t[i] + " ");
    }
    }