none
Platform::String RRS feed

  • General discussion

  • Hi

    I would like to know what is primary difference between String::Equals method and String::Operator==Operator(C++/CX)

    for String::Equals method the documentation states as below

    Indicates whether the specified object is equal to the current object.

    for String::Operator==Operator(C++/CX) the documentation states as below

    Indicates whether two specifed String objects have the same value.

    So, therefore am i correct in saying that String::Equals and String::Operator==Operator(C++/CX) serve the same purpose and if so, then why do we have two variants instead of only one.

    Regards,

    Srinivasan


    srinivasansaripalli

    • Changed type Mike FengModerator Tuesday, July 3, 2012 12:52 PM Everybody can give different answer
    • Changed type Mike FengModerator Tuesday, July 3, 2012 12:52 PM Everybody can give different answe
    Sunday, July 1, 2012 2:25 AM

All replies

  • yes you are right String.Equal is same as operator '=' that is actually syntactical shorthand for String.Equal that actually override Object.Equal  from which string object is derived for.
    Sunday, July 1, 2012 5:29 AM
  • Yes. They are same. And the reason for why 2 variants exist is just microsoft is giving more options. Some people like to use == and some people like to use Equals. There is no specific reason for this. 

    On the otherhand, In your classes, you can override Equals and == operator to give them different meanings. But, that might confuse your class users.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Monday, July 2, 2012 6:10 AM