C # Escape Character summary

Source: Internet
Author: User

Escape character \
• A special character constant;
• Start with a backslash "\" followed by one or several characters.
• Have a specific meaning, different from the original meaning of the character, it is called "escape" character.
• Used primarily to denote control codes that are not easily represented by ordinary characters.
• Its role is to eliminate the original meaning of the character immediately following it
• Use a combination of some ordinary characters instead of some special characters, because their combination changes the meaning of the original character representation, so called "escaping"
• Use a visible character to indicate a character that cannot be seen, such as ' \ n ' for a newline
Example: textbox.text= "You are \" Genius ", haha! "
What does it show?
Show: You are "genius" haha
Commonly used escape characters and their meanings
Escape character meaning
\ ' Single-quote character
\ "single-quote character
\ \ backslash character "\"
A/s null character (NULL)
\a Ringing Bell
\b Backspace
\f Paper Change page
\ nthe line break
\ r Enter
\ t jumps horizontally to the next tab position
\v Vertical tabs (vertical tab)
ASCII has some nonprinting characters, such as line breaks, bells, etc., these characters must be written directly to the ASCII value can be output, there is no law between these ASCII, readability is not high, difficult to remember, for this reason people invented the escape character to replace the ASCII value, to get rid of the disadvantage of ASCII, Convenient for people to use.
What's in C #?
Like what
string [email protected] "" +THIS.OPENFILEDIALOG1.FILENAME;
What's he talking about?
---------------
In C #, "c:\\temp" means that the path is C:\Temp
and @ "C:\Temp" means C:\Temp
So, the action of @ should be to ignore the escape character.
Do you think this understanding is correct?????????????
So what do you do if you want to show "\ T"?
Response.Write ("\" \\t\ "");
Display result: "\ t"
Today in writing a vb.net program, unexpectedly forget the vb.net escape double quotes, kept to use \ "to express, can be wrong!" Because of the habit of writing C # code, and then finally made clear, in the vb.net in the original is two double quotation marks to indicate "". Now just post these, and then fill it up!
C#
Escape character Name

\ ' Single quotation mark

\ "Double quotation marks

\ \ counter Slash

Space-out character

\a Exclamation Sign

\b Backspace

\f Page Change

\ n New Line

\ r Enter

\ t Horizontal tab

\v Vertical Tab
--------------
vb.net
Escape character Name
""   :            "
Member Constants equivalent description
---------------------------------------------------------------------------
CrLf vbCrLf CHR + CHR (10) Carriage return/line break combo. (CONTROLCHARS.CRLF)
Cr vbcr Chr (13) carriage return.
Lf vblf Chr (10) line break.
NewLine vbnewline CHR + chr (10) New line character.
The new, C #, and vb.net general-purpose methods that automatically adapt to environmental changes in the most standard. NET class libraries:
Environment.NewLine
Example: Dim str1 as String = "You" & Environment.NewLine & "Good"
C # escape character

The meaning of escaping character escaping characters
\ nthe carriage return to newline.
\ t jumps horizontally to the next tab position
\v Vertical Jump Lattice
\b Backspace
\ r Enter
\f Paper Change page
\ \ backslash character "\"
\ ' Single-quote character
\a Ringing Bell
\DDD the characters represented by the number of octal digits
\xhh the characters represented by hexadecimal digits
Output the change behavior in the text box \ r \ n
Escape characters in C #:
\ n-------------------------Line break
\ r-------------------------Enter
\ t-------------------------tab
\b-------------------------Backspace
\f-------------------------page Break
-------------------------empty symbol
\ "-------------------------double quotation marks
' '-------------------------single quotation mark
\ \-------------------------back slash
There is also a special, that is, the @ number, as long as the statement preceded by the @ sign, that is, after the @ number including the escape character is not escaped.

Transferred from: http://www.cnblogs.com/shengtianlong/archive/2010/06/11/1756366.html

C # Escape Character summary

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.