【发布时间】:2012-09-02 01:04:54
【问题描述】:
可能重复:
Most efficient way to test equality of lambda expressions
How to check if two Expression<Func<T, bool>> are the same
如何像这个示例一样测试两个表达式是否相同
string firstname = "Ahmed";
Expression<Func<string, bool>> exp1 = (s) => s.Contains(firstname);
Expression<Func<string, bool>> exp2 = (s) => s.Contains(firstname);
Console.WriteLine(exp1 == exp2);//print false as two references are no equal
现在如何确保 expression1 等于 expression2 ,因为它们具有相同的条件?
【问题讨论】:
标签: c# lambda expression