这个为什么老在THIS这报错呢/?。/。。
using System;
namespace _03_22
{
class Car
{
int[] wheels = new int[4];
public Car()
{
wheels[0] = 1;
wheels[1] = 2;
wheels[2] = 3;
wheels[3] = 4;
}
public int this [int index] // Carタ犒トヒニ・
{
get
{
return wheels[index];
}
set
{
wheels[index] = value;
}
}
// public int this [string wheel]
// {
// get
// {
// for(int i = 0; i < wheels.Length; ++i)
// {
// if(wheels[i] == wheel) return i;
// }
// return -1;
// }
// }
public int this [int wheels]
{
get
{
for(int j=0;j< wheels.Length;j++)
{
if( wheels[j]==wheel) return j;;//Console.WritrLine("You are clever");
}
return -1;
}
}
}
class Class_03_22
{
public static void Main(String[] args)
{
Car car1 = new Car();
// Console.WriteLine("car1オトモメヌーツヨハヌオレ{0}クヨラモ", car1["モメヌーツヨ"]);
// Console.WriteLine("car1オトラヨハヌオレ{0}クヨラモ", car1["ラヨ"]);
Console.WriteLine("car1オトラヨハヌオレ{0}クヨラモ", car1[2]);
Console.ReadLine();
}
}
}
问题点数:10、回复次数:6Top
1 楼sky911911(assda)回复于 2006-07-02 21:20:09 得分 0
自己顶一下。。。Top
2 楼UPCC(杂食动物)回复于 2006-07-02 22:07:04 得分 0
this 关键字,不能作为变量Top
3 楼worldstar(飓风)回复于 2006-07-03 00:02:53 得分 0
关注Top
4 楼gym333(阳光不生锈)回复于 2006-07-03 07:46:25 得分 0
关键字,换个别的变量名
Top
5 楼sky911911(assda)回复于 2006-07-03 08:53:57 得分 0
关键字,换个别的变量名??
怎么换??我换了也还是报错!!Top
6 楼awinder(风)回复于 2006-07-03 09:29:49 得分 0
参数相同的索引器不能有两个Top




