Reputation:
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
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("\"", "");
Upvotes: 1
Reputation: 709
Use a backslash to determine special character
string = string.Replace("\"", "");
Upvotes: 0
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.
methew wade watto
Upvotes: 0