Lan Unity Development Basics-using strings to learn notes

Source: Internet
Author: User

Lan Unity Development Basics using strings

Content in this section: Using Strings: string concatenation, escape characters

One, string concatenation: string can use + or + = string splicing!!

Second, transfer character--example \ n (for carriage return, line break)

Transfer character

Escape _ Escape Meaning

\n_ indicates a newline or carriage return

\t_ represents a tab character

\ "_ means double quotation marks

\ ' _ denotes single quotation marks

\\_ = backslash

Adding the @ symbol in front of the string invalidates the escape character of the string!

After a string literal is invalidated, we need to use two double quotation marks to print the double quotation marks

Source

usingSystem;

namespaceLesson08
{
    class MainClass
    {
         Public Static voidMain (string[] args)
        {


            The // string cannot be mathematically operated using subtraction, but you can use the operator symbol!
            // string concatenation
            stringname=" Lao Wang " ;
            stringsay =" Hello " ;
            // You can use the plus sign to stitch strings in a string
say = say + name;//" Hello Tokugawa Ieyasu "
            //+ + can also be used
            //say + = name;
            //console.writeline (say);

            // transfer character
            // Escape _ escape meaning
            //\n_ indicates a newline or carriage return
            //\t_ represents a tab character
            stringstr ="\ tLi Bai\ nbefore the bed was bright moonlight,\ nsuspicion is ground frost.  ";
            Console. WriteLine (str);

            //\ "_ means double quotation marks
            //\ ' _ denotes single quotation marks
            //\\_ = backslash
             After a string literal is invalidated, we need to use two double quotation marks to print the double quotes

            strings =" Lao Wang said: \"I'm not in the closet! I like to eat apples\\Banana\\Pear\"";
s =@ " Lao Wang said: ""I'm not in the closet! I like to eat apples \ bananas \ pears """;
            Console. WriteLine (s);
            stringSS = " use in strings \ n means line break! ";

            // How to Output the original \ n
            //1. in the \ n before adding a \
SS = " use in strings \\n means line break! ";
            //2. in front of the string, add @ symbol, it invalidates the escape character of the string!
SS =@ "Use \ n in a string to represent a newline!" ";
            Console. WriteLine (ss);

        }
    }
}

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/85/9F/wKioL1eqnTTghbGdAAAmjlMrvGY704.png-wh_500x0-wm_3 -wmp_4-s_1139292695.png "title=" qq picture 20160810110758.png "alt=" Wkiol1eqnttghbgdaaamjlmrvgy704.png-wh_50 "/>

Lan Unity Development Basics-using strings to learn notes

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.