Quotation mark in string

前端 未结 3 786
终归单人心
终归单人心 2020-12-21 05:27

I have some string with variable, e.g.

string path = @\"C:\\one\\filename.exe\" + arguments

arguments: \"-s -c -d > \"somedirectory\\some file.txt\"\"


        
相关标签:
3条回答
  • 2020-12-21 05:29
    string args = @"-s -c -d > ""somedirectory\some file.txt"""
    

    try that.

    for more information, http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx

    0 讨论(0)
  • 2020-12-21 05:33
    var arguments =  @"-s -c -d > ""somedirectory\some file.txt""";
    

    or

    var arguments = "-s -c -d > \"somedirectory\\some file.txt\"";
    
    0 讨论(0)
  • 2020-12-21 05:40

    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.

    0 讨论(0)
提交回复
热议问题