How can I replace a single quote (') with a double quote (") in a string in C#?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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("'","\"");
回答2:
var abc = "hello the're";
abc = abc.Replace("'","\"");
回答3:
string str;
str=strtext.Replace('"','\'');