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