I know Equals compare the value stored in the reference while "==" compares whether two references point to the same object.
No, that's just the behaviour of the default == operator for reference types. When both sides of == have a compile-time type of string, the bool operator==(string, string) overload declared in the string class is used, and you get the same result as Equals, when the target of the call isn't null.
That behaviour is exactly the same in regular code as in lambda expressions. Code written in a lambda expression should behave exactly the same way as code written not in a lambda expression... although if the lambda expression is converted to an expression tree, the compiler only emits the code as data, so it's up to whatever's consuming the expression tree to do the right thing with it.
So yes, the code should work absolutely fine - the only difference between using Equals and using == is that if you list contains any null elements, the x.Equals(...) call will throw a NullReferenceException. Personally I usually compare strings with == just for simplicity.
==operator orEqualsmethod work. Also,==does not necessarily "compare the reference" in C# as it does in Java - it is whatever sensible operator overload has been created. One difference that can bite fairly easily isnull.Equals(x)will throw an exception whereasnull == xwill not.x. Ifxis a string, it's going to call the==operator instring, which performs a value comparison. If the type ofxis object (compile-time type, that is) then it will perform a reference comparison.==. Ideally, tell us the motivation for the question, too... fundamentally, code in lambda expressions behaves as normal, assuming it's being converted to a delegate. (If it's being converted to an expression tree then the meaning should be the same, but it could be interpreted differently by whatever is consuming the tree.).Equalsdoes not "compare the value stored in the reference", it does whatever the programmer ofT.Equals(T)decided it should do, and in the context of strings it does a string value comparison, not a reference comparison, though surely two equal references means equal values as well, but even with different references, but the same value,.Equalson string will returntrue.