Created
June 29, 2011 05:24
-
-
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# )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region removeQuote | |
/// <summary> | |
/// Replace all double "s in a string with single 's | |
/// * this also removes " | |
/// </summary> | |
/// <param name="dirty"></param> | |
/// <returns></returns> | |
public static string replaceDoubleQuotes( string dirty ) | |
{ | |
char q1 = Convert.ToChar('"'); | |
char q2 = Convert.ToChar(0x0022); | |
string q3 = """; | |
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