0
我有被簡化以下遞歸方法:遞歸和變量值
private List<string> data;
public string Method1()
{
data = new List<string>();
//When Method 1 gets called first time there is a problem
//When Method 1 gets called from Method2 problem is fixed
if (problem)
{
data.Add("prob");
}
if(data.Count > 0)
{
return Method2()
}
else
{
return string.Empty();
}
}
private string Method2()
{
return Method1();
}
方法1時從被稱爲方法2我在正確的思維是,data
變量重新初始化在那裏抹了什麼以前?
這樣想的。有一個奇怪的錯誤,當Method1從Method2調用時,它仍然說有問題,並想知道是否因爲List中有最初的數據,但我確信遞歸會消除它。 – Jon 2012-07-14 10:37:09