Reputation: 1518
How can I replace a single quote (') with a double quote (") in a string in C#?
Upvotes: 37
Views: 96090
Reputation: 109027
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("'","\"");
Upvotes: 55
Reputation: 19
string str; str=strtext.Replace('"','\'');
Upvotes: 1
Reputation: 27377
var abc = "hello the're"; abc = abc.Replace("'","\"");
Upvotes: 8