ASP.NET 中关于递归的问题

chxn220 chxn220 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
protected void ibt_update_type_Click(object sender, EventArgs e)
{
DataTable dt = bs.GetDictionary(" ").Table;
for (int i = 0; i < dt.Rows.Count; i++)
{
string pid = dt.Rows[i]["tp_id"].ToString();
string classid = pid + ",";
classid = GetBindNode(classid, pid);
classid = classid.Substring(0, classid.Length - 1);
bool isbo = be.update_class(classid, pid);
}
}
//绑定子分类
string GetBindNode(string classid, string parentid)
{
DataTable smdt = bs.GetDictionary(" and tp_ParentId= " + parentid).Table;
int it = smdt.Rows.Count;
if (it == 0)
{
return classid;
}
else
{
for (int i = 0; i < smdt.Rows.Count; i++)
{
string csid = smdt.Rows[i]["tp_id"].ToString();
classid += smdt.Rows[i]["tp_id"].ToString() + ",";
GetBindNode(classid, csid);
}
}
return classid;
}
为什么我让it等于O的时候退出这个方法 ,但是为什么他不退出继续执行for循环里面的GetBindNode方法,这样导致classid里面只能追加两个,其它的都追加不上。谢谢各位。。我头疼一天了。。。帮帮忙。。。
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
chxn220
JavaScript 87,984 成员 224,681 内容