Tim*_*ora 13
我假设(因为问题不清楚而大的假设)你想在你的字符串中加双引号.为此,您可以使用逐字字符串文字语法.
string s = @"""my string""";
Run Code Online (Sandbox Code Playgroud)
您也可以手动转义双引号:
string s = "\"my string\"";
Run Code Online (Sandbox Code Playgroud)
string a = "hello, world"; // hello, world
string b = @"hello, world"; // hello, world
string c = "hello \t world"; // hello world
string d = @"hello \t world"; // hello \t world
string e = "Joe said \"Hello\" to me"; // Joe said "Hello" to me
string f = @"Joe said ""Hello"" to me"; // Joe said "Hello" to me
string g = "\\\\server\\share\\file.txt"; // \\server\share\file.txt
string h = @"\\server\share\file.txt"; // \\server\share\file.txt
string i = "one\r\ntwo\r\nthree";
string j = @"one
two
three";
Run Code Online (Sandbox Code Playgroud)
string s = "\"blabla\"";
Run Code Online (Sandbox Code Playgroud)
这将使 " 保持在字符串内