我有一个简化的递归方法:
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();
}
当 Method1 从 Method2 调用时,我是否正确地认为该data
变量已重新初始化,从而消除了以前的内容?