添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
帅呆的匕首  ·  Selenium - 元素等待(2) - ...·  4 月前    · 
大气的手电筒  ·  spring ...·  1 年前    · 
爱看球的企鹅  ·  java - How to nest ...·  1 年前    · 
        class Program    {        static void Main(string[] args)        {            C[] cs = new C[]{            new C(11),new C(22),new C(33),            new C(44),new C(55),new C(66)};             Expression<Func<C, bool>> e1 = x => x.N > 20;            Expression<Func<C, bool>> e2 = x => x.N < 50;             Expression<Func<C, bool>> e3 = e1.AndAlso(e2);             var re = cs.Where(e3.Compile()).ToArray();             foreach (C c in re)                Console.WriteLine(c.N);            //22 33 44            Console.ReadLine();        }    }     //元素类型定义    class C    {        public C(int n) { this.N = n; }        public int N;    }     //扩展方法    public static class Ext    {        public static Expression<Func<T, bool>> AndAlso<T>(  this Expression<Func<T, bool>> a,  Expression<Func<T, bool>> b)        {            var p = Expression.Parameter(typeof(T), "x");            var bd = Expression.AndAlso(                    Expression.Invoke(a, p),                    Expression.Invoke(b, p));            var ld = Expression.Lambda<Func<T, bool>>(bd, p);            return ld;        }    }