class intDex
{
private string[] myData;
public intDex(int size)
{
myData = new string [size];
for (int i = 0; i < size; i++)
{
myData[i] = "空值";
}
}
public string this[int pos]
{
get { return myData[pos]; }
set { myData[pos] = value; }
}
}
class Program
{
static void Main(string[] args)
{
int size = 10;
intDex myInd = new intDex(size);
myInd[2] = "我是2";
myInd[4] = "我是4";
myInd[8] = "我是8";
for (int i = 0; i < size; i++)
{
Console.WriteLine("myInd[{0}]:{1}",i,myInd [i ]);
}
Console.ReadLine();
}
}