索引器允许为对类或结构的实例进行数组一样的操作提供索引。
using System;

class testIndexers

...{
private string []arr=new string[10];

public string this[int j]

...{

get...{return arr[j];}

set...{arr[j]=value;}
}
}


class Client

...{
static void Main()

...{
testIndexers indexer=new testIndexers();
indexer[0]="Hello world!";
Console.WriteLine(indexer[0]);
}
}






























编译运行。