Tuesday, November 27, 2007

What is diffrenece between string.compare and string.compareordinal

String.Compare can be or not be case-sensitive, and can incorporate anynumber of comparison options, including culture-sensitivity and sortingrules. That is, it is not comparing the exact strings necessarily, but canbe configured to do various sorts of comparisons. String.CompareOrdinalcompares the numeric values of the individual Unicode characters of thestrings. In other words, it is always case-sensitive, and neverculture-sensitive.

String.CompareOrdinal is faster (more efficient) when you don't need to do aculture-sensitive comparison, and you do want to do a case-sensitivecomparison.String.CompareTo is case-sensitive, using an Ordinal comparison, andculture-sensitive, but always uses the current culture. It is faster thanString.Compare, but less efficient than String.CompareOrdinal.
Share:

0 comments:

Post a Comment

Your feedback is very important to me. Please provide your feedback via putting comments.

Search This Blog
Loading...
About Me
My Photo

Full Stack Developer,Blogger,Microsoft Mvp, Mentor, Life long learner, 10+ Years of Experience for JavaScript, web and Microsoft technologies. ASP.NET MVC,Web Forms,C#,AngularJs,Golang
Mvp profile
Subscribe to my blog

Enter your email address:

Follow us on facebook
Blog Archive
Total Pageviews