日期:2014-05-18 浏览次数:21070 次
class test
{
private int[] myint = new int[10];
public string name = "hello world";
public test()
{
for (int i = 0; i < 10; i++)
{
myint[i] = i;
}
}
public int this[int n]
{
get
{
return myint[n];
}
set
{
myint[n] = value;
}
}
}
static void Main(string[] args)
{
test[] t = new test[10];
Console.WriteLine(t[5]);
}
test[] t = new test[10] for(int i =0;i<10;i++)t[i]=new test();
------解决方案--------------------
楼主没明白数组的意思
test[] t1
test t
是两个不一样的东西
t1 其实是Array 而非 test
通过[] 不是调用的索引器