一个简单的问题!!!!!高手马上就可以解决!
private TreeNode searchtreeview(string year,string month,string day)//如果没有记录,则返回null,有年tny,有月tnm,有日tnd,
{
int cny = tvlog.Nodes[0].Nodes.Count;
if (cny != 0)
{
foreach(TreeNode tny in tvlog.Nodes[0].Nodes)
{
if (year == tny.Text)
{
MessageBox.Show("当前年纪录已经存在");
//查找到年记录存在,继续查找月记录是否存在
foreach(TreeNode tnm in tny.Nodes)
{
if (month == tnm.Text)
{
MessageBox.Show("当前月记录已经存在");//找到月记录,继续查找日记录
foreach(TreeNode tnd in tnm.Nodes)
{
if (day == tnd.Text)
{
MessageBox.Show("找到日记录");
return tnd;
}
else//没有相匹配的日,返回tnm
{
return tnm;
}
}
}
else//如果月记录不存在,则返回tny
{
return tny;
}
}
}
else//没有相匹配的年纪录,返回null
{
return null;
}
}
}
else
{
return null;
}
}
这样一段代码,出现错误:
F:\My Documents\Visual Studio Projects\上网计时\Main.cs(444): “上网计时.FrmMain.searchtreeview(string, string, string)” : 并非所有的代码路径都返回值
我还是看不出来,请大家帮忙.