字符串中的引号
我有一些带有变量的字符串,例如
string path = @"C:\one\filename.exe" + arguments
arguments: "-s -c -d > "somedirectory\some file.txt""
我在将输出重定向到 "somedirectory\some file"
时遇到问题 如果我输入 "\""
或 char.ToString('"')
它总是解释为 \"
...而不是单独 "
我应该如何将这个 "
字符放入参数中?
I have some string with variable, e.g.
string path = @"C:\one\filename.exe" + arguments
arguments: "-s -c -d > "somedirectory\some file.txt""
I've problem with redirection output to "somedirectory\some file"
If I put "\""
or char.ToString('"')
it always interprets as \"
...not alone "
How should I put this "
character into arguments?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要使用
\"
。调试器将其显示为
\"
,因为它显示有效的字符串文字。但是,字符串中的实际值是
"
。(您可以在文本可视化工具中看到这一点)在逐字字符串文字 (
@"..."
) 中,您可以需要使用""
代替。You need to use
\"
.The debugger shows it as
\"
, since it shows valid string literals.However, the actual value in the string is
"
. (You can see this in the Text Visualizer)In a verbatim string literal (
@"..."
), you need to use""
instead.或者
or
尝试一下。
有关详细信息,http://msdn.microsoft .com/en-us/library/aa691090%28v=vs.71%29.aspx
try that.
for more information, http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx