zoukankan      html  css  js  c++  java
  • 返回最大深度

     Console.WriteLine(GetMaxDepth(list));
    public static int GetMaxDepth(List<Department> list, int? id = null)
            {
                if (list == null) throw new Exception("未将对象引用设置到对象的实例。");
                var depaList = list.Where(x => x.FParentID == id).ToList();
                if (depaList.Count == 0) return 0;
                int max = 0;
                foreach (var item in depaList)
                {
                    if (GetMaxDepth(list, item.FID) > max)
                    {
                        max = GetMaxDepth(list, item.FID);
                    }
                }
                return ++max;
                //Func<Guid, int> fun = null;
                //fun = new Func<Guid, int>(x =>
                //{
                //    return 1;
                //});
                //fun = delegate(Guid s)
                //{
                //};
            }
    

      

  • 相关阅读:
    重要的环境变量
    常用的转义字符
    常用系统工作命令
    栈 队列 和 双向队列
    时间
    默认值字典
    Counter
    random
    22 内置常用模块01
    super
  • 原文地址:https://www.cnblogs.com/malianyong/p/4233840.html
Copyright © 2011-2022 走看看