Possible Duplicate:
Differences in string compare methods in C#
Is there any difference between these methods?
string.Compare(s1, s2) == 0
s1.CompareTo(s2) == 0
s1.Equals(s2)
s1 == s2
Which one should I use?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From reflector:
So
CompareTohas an additional reference check thanCompare.So
==is exactly the same asEquals.The difference between two
Compareand twoEqualsis, you can passCompareOptionsargument toCompare, and it returns 0/1/-1. whileEqualsdoesn’t receive aCompareOptionsargument, and it can tell you TRUE/FALSE only.