c# 递归函数使用案例

/// <summary>
/// 递归查询
/// </summary>
/// <param name="groupID"></param>
/// <param name="idList"></param>
protected static void FindChildrenID(int groupID, StringBuilder idList)
{
// 这里是找孩子节点
var gLst = RepositoryFactory.Group.FindList(p => p.ParentID == groupID, "ID", false).ToList(); foreach (var item in gLst) { //判断子节点是否存在,有则继续   if (RepositoryFactory.Group.Find(p => p.ParentID == item.ID) != null)   return FindChildrenID(item.ID, idList); idList.Append("|" + item.ID.ToString()); } }

 

posted @ 2017-02-25 12:49  骚年丶勿忘初心。  阅读(1727)  评论(0编辑  收藏  举报