C# difference between == and Equals()

前端 未结 17 1358
走了就别回头了
走了就别回头了 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:38

    Just as an addition to the already good answers: This behaviour is NOT limited to Strings or comparing different numbertypes. Even if both elements are of type object of the same underlying type. "==" won't work.

    The following screenshot shows the results of comparing two object {int} - values

提交回复
热议问题