本文介绍了我可以在逐字字符串文字中转义双引号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C# 中的逐字字符串文字 (@"foo") 中,反斜杠不被视为转义符,因此执行 " 来获得双引号不起作用.有没有办法在一个双引号中获得双引号?逐字字符串文字?

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";

推荐答案

使用重复的双引号.

@"this ""word"" is escaped";

输出:

this "word" is escaped

这篇关于我可以在逐字字符串文字中转义双引号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 12:43
查看更多