Reputation: 507
I'm trying to delete the "
character from my string. But I don't succeed. I'm doing :
char[] liste = { '\"' };
response = response.Trim(liste);
or:
response = response.Trim('\"');
But it does not succeed. I have another question. I would like to replace for example in this string:
"token" : "scsdsd,vkf,vfk,"
Delete just the "
that wraps the token. I don't know if it's possible or if I have to do my own parser. Thanks
Upvotes: 0
Views: 85
Reputation: 395
try this and let me know if it doesn't work
var str = '\"';
str = new string((from c in str
where char.IsWhiteSpace(c) || char.IsLetterOrDigit(c)
select c
).ToArray());
Upvotes: 0
Reputation: 2675
Check the following code:
class Program
{
static void Main(string[] args)
{
char[] list = { '\"' };
string response = "\"bla\"";
response = response.Trim(list);
Console.WriteLine(response);
Console.ReadLine();
}
}
" were trimmed. Of course, trimming works at the beginning and the end of strings. If you want to remove all " from the string, then you can use Replace()
.
Upvotes: 0
Reputation: 1038780
You could try using the string.Replace
method in order to replace all occurrences of a given string with another:
reponse = reponse.Replace("\"", string.Empty);
Upvotes: 1