我能逃脱在逐字字符串双引号? [英] Can I escape a double quote in a verbatim string literal?
本文介绍了我能逃脱在逐字字符串双引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在一个逐字字符串(@富)在C#中,反斜杠不被视为逃逸,这样做\\来获得一个双引号不起作用。有没有什么办法让一个双引号逐字字符串?
这可以理解不起作用:
串富= @这个\\这个词\\转义
解决方案
使用重复的双引号。
@这个字转义
输出:
是躲过了这场字
In a verbatim string literal (@"foo") in C#, backslashes aren't treated as escapes, so doing \" to get a double quote doesn't work. Is there any way to get a double quote in a verbatim string literal?
This understandably doesn't work:
string foo = @"this \"word\" is escaped";
解决方案
Use a duplicated double quote.
@"this ""word"" is escaped";
outputs:
this "word" is escaped
这篇关于我能逃脱在逐字字符串双引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文