Performance of expression trees
问题 My current understanding is that 'hard coded' code like this: public int Add(int x, int y) {return x + y;} will always perform better than expression tree code like this: Expression<Func<int, int, int>> add = (x, y) => x + y; var result = add.Compile()(2, 3); var x = Expression.Parameter(typeof(int)); var y = Expression.Parameter(typeof(int)); return (Expression.Lambda(Expression.Add(x, y), x, y). Compile() as Func<int, int, int>)(2, 3); as the compiler has more information and can spend more