For differences between string. Compare and C ++ in. net, please explain why?

Source: Internet
Author: User

All comparisons in this document are case sensitive.

In C ++:

"A" <"A": True

"AA" <"A": True

"AA" <"AA": True

"AA" <"AA": True

"AC" <"AB": True

Obviously, in C ++, string comparison follows the following two rules:

1. Lower case <upper case

2. Comparison from the beginning to the back. This deduction is to ignore the overall length.

I personally think this is very reasonable, that is, the way the English dictionary is sorted.

 

But let's look at the results in. net.

String: Compare ("A", "A"):-1

String: Compare ("AA", "A"): 1 //. Net considers the overall length.

String: Compare ("AA", "AA"):-1

String: Compare ("AA", "AA"):-1

String: Compare ("AC", "AB"): 1 // This is the least I can understand. It is case-sensitive. Why does. Net ignore the differences between the first a and even the second character?

I don't know if there are any other string comparison methods in. net? It is difficult to sort dictionaries using this method.

If Microsoft's comparison result is by design, what kind of actual environment does Microsoft target?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.