c# 匿名委托递归

            Func<List<int>, int> GetVirtualCode = null;  // 递归不能直接=,要赋初值。微软得优化啊,这语法糖不够甜
            GetVirtualCode = delegate(List<int> args)
            {
                if (args.Count == 0)
                    return 0;

                if (args.Count == 1)
                    return args[0];

                return args[0] | GetVirtualCode(args.Skip(1).ToList());
            };

 

posted on 2019-05-25 17:54  空明流光  阅读(333)  评论(0编辑  收藏  举报

导航