你需要一个值来使用属性
如你的:public int doorNum属性
就需要一个int 变量来使用
int DoorNum
public int doorNum
{
get
{
return DoorNum;
}
set
{
if(value>=0 && value<=10)
DoorNum=value;
}
如你的:public int doorNum属性
就需要一个int 变量来使用
int DoorNum
public int doorNum
{
get
{
return DoorNum;
}
set
{
if(value>=0 && value<=10)
DoorNum=value;
}
例如:在类Transportation
public Transportation()
{
wheelNum=4;
doorNum=2;
maxSpeed=(float)55.0;
}这3个变量没有声明就用了.
if(value>=0 && value<=10) //运行到此处时系统指出StackOverflowExceptionwheelNum=value;
你出错那句也是这样.
----------------------------------------
To teach a fish how to swim.
----------------------------------------
To teach a fish how to swim.