[問題] 使用properties跑出無窮迴圈或無窮遞迴的警告
在一開始未把相關變數改成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
推
12/07 00:44, , 1F
12/07 00:44, 1F
→
12/07 00:51, , 2F
12/07 00:51, 2F
推
12/07 01:41, , 3F
12/07 01:41, 3F