C# difference between == and Equals()

前端 未结 17 1406
走了就别回头了
走了就别回头了 2020-11-21 06:56

I have a condition in a silverlight application that compares 2 strings, for some reason when I use == it returns false while .Equals()

17条回答
  •  一整个雨季
    2020-11-21 07:49

    As far as I understand it the answer is simple:

    1. == compares object references.
    2. .Equals compares object content.
    3. String datatypes always act like content comparison.

    I hope I'm correct and that it answered your question.

提交回复
热议问题