关于递归返回值的问题
public string GetStringText(TreeNode node)
{
string str = " ";
if (node == null)
return str;
else
{
str = node.Text.Trim() + " <-- " + str;
if (node.Parent != null)
{
this.GetStringText(node.Parent);
}
else
return str.Substring(0,str.Length-3);
}
}
总是报‘并非所有的代码路径都返回值’
大家帮我看看
------解决方案--------------------public string GetStringText(TreeNode node)
{
if (node.Parent == null)
return node.Text.Trim();
else
{
return node.Text.Trim() + " <-- " + this.GetStringText(node.Parent);
}
}
//是否为LZ想要实现的?