Using == or Equals for string comparison

后端 未结 5 1103
抹茶落季
抹茶落季 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:32

    There is no technical difference (unless aa is null). Use whatever looks better to you. In my opinion, using operator overloads makes the code clearer.

    Use functions when you need (or might need in future) their additional arguments (as in CompareTo())

提交回复
热议问题