作者Dacool (大裤)
看板C_Sharp
标题[问题] 使用properties跑出无穷回圈或无穷递回的警告
时间Sun Dec 7 00:28:12 2008
在一开始未把相关变数改成properties使用时,只是单纯的用get跟set的function
改成properties後,每次run程式时,正当我有call到properties里的get
那就会在get的return x那边,跳出查看是否有无穷回圈的这警告
call set时,就是 X = value那边
我properties是写在base class里,想请问一下到底怎麽了。
public int X
{
get
{ -----------
|return X;| ------StackOverflowExceptio 未处理
----------- 请确定没有无限回圈,或无限递回的情况。
}
set
{
X = value;
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.115.145.24
1F:推 toki:你的 proterty Get X 又 return X,根本就鸡生蛋蛋生鸡啊 12/07 00:44
2F:→ Dacool:哈...蠢毙了...感谢 12/07 00:51