Click here to Skip to main content
16,012,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi....
I am newbie in C#.I am not getting what is difference between compare and compareto to in C#.

Difference between string.compare(str1,str2) and str1.compareto(str2)
??
Posted

Hi,

Have a look here:
http://social.msdn.microsoft.com/Forums/en-US/44fafe4a-324f-4fe5-9c79-477e68923f96/what-si-difference-between-stringcompare-stringcompareto-and-in-c?forum=csharpgeneral[^]

Short explained: Compare() is very similar to CompareTo(), but is useful if the first string can be null, because Compare() can handle null strings.
 
Share this answer
 
v2
Comments
1989priya 8-Jan-14 11:50am    
Hi ProgramFox
Thanks for reply.

I read this link but I am not getting.....
Thomas Daniels 8-Jan-14 11:54am    
I updated my answer.
1989priya 8-Jan-14 12:30pm    
Thankx ProgramFox
Now I got it
Thomas Daniels 8-Jan-14 12:31pm    
You're welcome!
Hi ProgramFox
Thanks for reply.

I read this link but I am not getting.....
 
Share this answer
 
Comments
Thomas Daniels 8-Jan-14 11:48am    
First of all, if you have a comment to my answer, then please click on the "Have a Question or Comment?" button below my answer, then you can post a comment there.

I'll update my answer.
Thomas Daniels 8-Jan-14 11:54am    
Because you added your comment as a comment to my answer, you can delete this answer.
Sergey Alexandrovich Kryukov 11-Mar-14 15:47pm    
Not an answer. Such posts are considered as abuse.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900