In verbatim string literals (@"..."
) a "
in the string value is encoded as ""
, which happens to also be the only escape sequence in verbatim strings.
@"\""Happy coding!\""" // => \"Happy coding!\"
"\\\"Happy coding!\\\"" // => \"Happy coding!\"
Note that in the 2nd case (not a verbatim string literal), a \
is required before the \
and the "
to escape them and prevent their normal meanings.
See the C# string reference for more details and examples.
单纯的字符串的话,直接加\进行转义。但是在@开头的字符串中,使用""来表示"