Jump to content

String::Compare

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Guest_NeedHelp_*

Guest_NeedHelp_*
  • Guests
Something that has always annoyed me about managed C++ is not having the ability to compare strings like


String^ c = "this";

String^ d = "that";


if (c == d) {}


instead you have to use code like


String^ c = "this";

String^ d = "that";


if (String::Compare(c,d) == 0) {

....

}



Why is this? And why does 0 equal true? hasn't 1 always been the value that equals true? Why did they have to change the entire language. It doesn't even resemble ANSI C++.

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Not sure why they changed it like that but it annoys me as well. True is now 0 because anything other than 0 is false. That means it can be -12000 or 100 to be false.

#3
brackett

brackett

    Programmer

  • Members
  • PipPipPipPip
  • 192 posts
Uhh...doesn't strcmp use the same returns?

#4
RobSoftware

RobSoftware

    Programmer

  • Members
  • PipPipPipPip
  • 143 posts
Its not just String::Compare but everything now returns 0 for true in managed C++.