C#中的转义字符verbatim string
2024-10-20 00:40:12
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.
单纯的字符串的话,直接加\进行转义。但是在@开头的字符串中,使用""来表示"
最新文章
- [深入学习Web安全](5)详解MySQL注射
- thinkphp3.2!Go for it!
- java JFrame窗体真正关闭
- MySql的count统计结果
- Docker私有仓库Registry的搭建验证
- java jdbc----mysql的select、insert、update、delete
- hdu 1381 Crazy Search
- 特性(Attributes)
- java学习 (2)xml操作 SAX(增、删、改、查)
- java_web学习(1)理解JavaBean
- C/s从文件(TXT)中读取数据插入数据库
- 【java设计模式】【行为模式Behavioral Pattern】迭代器模式Iterator Pattern
- 团队作业7——第二次项目冲刺(Beta版本计划及安排)
- 在使用mysql8.0的时候遇到的密码链接问题
- Chrome &; QR Code Reader
- 【rabbitmq】安装卸载
- 线程间通信wait和notify【All】简介
- MySQL: Connection Refused,调整 mysql.ini中的 max_connections
- Linux LVM逻辑卷配置过程详解(创建,增加,减少,删除,卸载)
- 字符串最长子串匹配-dp矩阵[转载]