蛮复杂的定义出错~~高手进~~
public struct box{
public bool Bvisible;
public int Bvalue;
public int BLocation;
}
class HBox
{
public static int BoxNum = 21;
public static int BoxC = 4;
public box[] allbox = new box[HBox.BoxNum*BoxC];
public box this[int H]
{
get
{
if (H > BoxNum * BoxC || H < 0)
throw new Exception("超出范围!");
else
{
return allbox[H];
}
}
set
{
if (H > BoxNum * BoxC || H < 0)
throw new Exception("超出范围!");
else
{
allbox[H] = value;
}
}
}
我实例化一个Hbox
Hbox h = new Hbox();
h[1].bool = fals //这一条会出错 ,为什么?
--------------------编程问答-------------------- 错误太多了
1、没有Hbox 类,是HBox
2、h 是HBox 的一个对象,不是数组
3、bool 是关键字,不能做为字段
4、bool 是box的字段,不是HBox
3、fals 拼写错了
4、少了一个分号
4、这样试试:h.allbox[1].Bvisible = false;
--------------------编程问答-------------------- 不好意思 ,,我重新整理了一下~~再发 --------------------编程问答-------------------- --------------------编程问答-------------------- 写写好了再发吧 --------------------编程问答--------------------
--------------------编程问答--------------------
补充:.NET技术 , C#