ara*_*een 5 c# string escaping double-quotes
我试图逃脱\并"在我的字符串中像这样:
text.Replace("\\", "\\\\").Replace("\"", "\\\"");
Run Code Online (Sandbox Code Playgroud)
但结果为text,
arash "moeen"
Run Code Online (Sandbox Code Playgroud)
结果是
text.Replace("\\", "\\\\").Replace("\"", "\\\"");
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
仅用于@逐字字符串。
text.Replace(@"this", @"that");
Run Code Online (Sandbox Code Playgroud)
例子:
text.Replace(@"\", @"\\").Replace(@"""", @"\""");
Run Code Online (Sandbox Code Playgroud)