在字符串引号 [英] Quotation mark in string
本文介绍了在字符串引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些字符串变量,如:
I have some string with variable, e.g.
string path = @"C:\one\filename.exe" + arguments
arguments: "-s -c -d > "somedirectory\some file.txt""
我和重定向输出问题somedirectory\some文件
。如果我把\
或 char.ToString('')
它总是解释为 \
...not单独
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?
推荐答案
您需要使用 \
。
调试器显示为 \
,因为它显示有效字符串。结果
然而,字符串中的实际值。 (您可以在文本展台看到这一点)
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.
这篇关于在字符串引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文