gpt4 book ai didi

c# - 如何测试表达式是否相等

转载 作者:太空宇宙 更新时间:2023-11-03 20:23:10 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
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 ,因为它们具有相同的条件?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com