Skip to content

Instantly share code, notes, and snippets.

@DoubleBrotherProgrammer
Created June 29, 2011 05:24
Show Gist options
  • Save DoubleBrotherProgrammer/1053212 to your computer and use it in GitHub Desktop.
Save DoubleBrotherProgrammer/1053212 to your computer and use it in GitHub Desktop.
Replace all double quotes in a string with single quotes using C-SHARP ( C# )
#region removeQuote
/// <summary>
/// Replace all double "s in a string with single 's
/// * this also removes &quot;
/// </summary>
/// <param name="dirty"></param>
/// <returns></returns>
public static string replaceDoubleQuotes( string dirty )
{
char q1 = Convert.ToChar('"');
char q2 = Convert.ToChar(0x0022);
string q3 = "&quot;";
char single_quote = '\'';
string clean = dirty.Replace( q1, single_quote );
clean = clean.Replace(q2, single_quote);
clean = clean.Replace( q3, single_quote.ToString() );
return clean;
}
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment