字符串将单引号替换为C#中的双引号

kst*_*kst 26 c# string replace

如何在C#中的字符串中用双引号(")替换单引号(')?

Bal*_*a R 42

您需要为引号符号使用正确的转义序列,您可以在此处找到有关转义序列的更多信息.

String stringWithSingleQuotes= "src='http://...';";
String withDoubleQuotes = stringWithSingleQuotes.Replace("'","\"");
Run Code Online (Sandbox Code Playgroud)


Rob*_*Rob 6

var abc = "hello the're";
abc = abc.Replace("'","\"");
Run Code Online (Sandbox Code Playgroud)