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