Using == or Equals for string comparison

后端 未结 5 1098
抹茶落季
抹茶落季 2020-12-14 23:48

In some languages (e.g. C++) you can\'t use operators like == for string comparisons as that would compare the address of the string object, and not the string itself. Howev

5条回答
  •  佛祖请我去吃肉
    2020-12-15 00:21

    Best-practise-wise, I would tend to always use an Equals() function for string comparison. This makes it clear when someone else reads your code that you specifically want the strings compared.

提交回复
热议问题