Lambda Expression: == vs. .Equals()

前端 未结 6 809
名媛妹妹
名媛妹妹 2021-01-07 23:09

This is a purely academic question, but what\'s the difference between using == and .Equals within a lambda expression and which one is preferred?

Code exam

6条回答
  •  时光取名叫无心
    2021-01-07 23:17

    They can be overloaded separately, so they could provide different answers. See http://msdn.microsoft.com/en-us/library/ms173147(VS.80).aspx which discusses how to overload each. Typically they will be the same, but there's no guarantee of that. So it depends on what type the lambda object is.

提交回复
热议问题