简体   繁体   English

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

[英]string replace single quote to double quote in C#

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

You need to use the correct escape sequence for the quotes symbol, you can find more information about escape sequencies here . 您需要为引号符号使用正确的转义序列,您可以在此处找到有关转义序列的更多信息。

String stringWithSingleQuotes= "src='http://...';";
String withDoubleQuotes = stringWithSingleQuotes.Replace("'","\"");
var abc = "hello the're";
abc = abc.Replace("'","\"");
string str;
str=strtext.Replace('"','\'');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM