How can I replace a single quote (') with a double quote (") in a string in C#?
Use the String. replace() method to replace double with single quotes, e.g. const replaced = str. replace(/"/g, "'"); . The replace method will return a new string where all occurrences of double quotes are replaced with single quotes.
Use the String. replace() method to replace single with double quotes, e.g. const replaced = str. replace(/'/g, " ); . The replace method will return a new string where all occurrences of single quotes are replaced with double quotes.
To place quotation marks in a string in your code In Visual Basic, insert two quotation marks in a row as an embedded quotation mark. In Visual C# and Visual C++, insert the escape sequence \" as an embedded quotation mark.
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("'","\"");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With