Friday, 28 December 2012

Remove a backslash character from a string in C#

Remove a backslash character from a string in C# 




String str = "\"Hello\" \"World\"";

Console.WriteLine(str);

output: "Hello" "World";

Case1://Remove/replace  backslash with Empty char
str = str.Replace('"',' ');
Console.WriteLine(str);

output:Hello World

Case 2://Remove/replace  backslash with single quote '
str = str.Replace('"',@''');
Console.WriteLine(str);

output:  'Hello' 'World'


No comments:

Post a Comment