首页 > Windows开发 > 详细

C#中的转义字符verbatim string

时间:2019-01-15 11:12:57      阅读:234      评论:0      收藏:0      [点我收藏+]

In a verbatim string (a string starting with @"") to escape double quotes you use double quotes, e.g. @"Please press ""Ok"".". If you want to do it with verbatim strings then you would do something like @"\""" (that‘s 3 double quotes on the end there).

 

 

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.

 

单纯的字符串的话,直接加\进行转义。但是在@开头的字符串中,使用""来表示"

 

C#中的转义字符verbatim string

原文:https://www.cnblogs.com/chucklu/p/10270739.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!