C # CompareTo Comparison of strings that makes me wonder where

Source: Internet
Author: User

The Copareto method is used when learning to choose the sorting algorithm. Because of the comparison of the number, it is at random input.

When I enter the string "8", it is compared to the string "16".

            String str1 = "8";            String str2 = "+";            String str3 = "n";            Console.WriteLine (Str1.compareto (STR2));//Results show 1            Console.WriteLine (Str3.compareto (STR2));//Results show-1

Obviously, I originally thought that "8" and "16" compare, the result is-1. It's not true.

As for, why the string "8" compares to the string "16" returns 1. For this reason, to be sure.

Todo

C # CompareTo Comparison of strings that makes me wonder where

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.