Take the 2-minute tour ×

How can I replace a single quote (') with a double quote (") in a string in C#?

share|improve this question
add comment

3 Answers

up vote 18 down vote accepted

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("'","\"");
share|improve this answer
add comment
var abc = "hello the're";
abc = abc.Replace("'","\"");
share|improve this answer
add comment
string str;
share|improve this answer
add comment

Your Answer


