user6656728
user6656728

Reputation:

conversion of special character string

i am using a web service and result is coming like this

" methew wade watto"

then I've tried with string.replace():

jsona = jsona.Replace(@"", "");

but the problem is i am unable to replace special character's like " this in my replace statement, How can I replace " from the input string? and what are the other options of replacing the string other then this?

Upvotes: 1

Views: 47

Answers (3)

sujith karivelil
sujith karivelil

Reputation: 29036

In c#, The @ symbol means to read that string literally, and don't interpret control characters otherwise. whereas \ followed by a character that is not recognized as an escaped character, matches that character.

So you have to use \" to represent " in .Replace() instead for @ I think you have to try something like this:

string jsonInput = "\"methew wade watto\""; // be the input 
string replacedQuotes = jsonInput.Replace("\"", "");

Working example

Upvotes: 1

MrVoid
MrVoid

Reputation: 709

Use a backslash to determine special character

string = string.Replace("\"", "");

Upvotes: 0

Ehsan Sajjad
Ehsan Sajjad

Reputation: 62498

You need to escape the " with \ , right now, you are just saying to replace empty string with empty string:

jsona= jsona.Replace("\"","");

Now this will replace the " sign in your string with empty string.

Output:

methew wade watto

Upvotes: 0

Related Questions