Novice C#string Class common functions of learning 2018.08.04

Source: Internet
Author: User

ToLower () is used to change the string to lowercase, note the immutable nature of the string, and need to reassign the value to another string variable.

            s = S.tolower (); // strings are immutable and need to be re-assigned after conversion, not just s. ToLower ();

This allows the user's input to be case insensitive, such as a captcha.

ToUpper () is used to capitalize all strings, similar to the above.

Trim () can be used to remove spaces on both sides.

            string "   a b c  ";             = S1. Trim (); // used to remove spaces on both sides of a string            Console.WriteLine (S1);

Equals () is used to compare strings, which contain multiple overloaded methods.

            string " Admin " ;             string " Admin " ;             // the comparison of ignoring case is StringComparison.OrdinalIgnoreCase            Console.WriteLine (S1. Equals (s2,stringcomparison.ordinal));

String. Format () to generate a new string with placeholders and formats.

            string string. Format (" I call {0}, I {1} years old ""www");            Console.WriteLine (s1);

2018.08.04

Novice C#string Class common functions of learning 2018.08.04

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.