How to find double quotes in a string in C #

If the string contains double quotes,

string str = "it is a "text""

how can i find out if there is a line? or not.

And how can I remove double quotes?

+3
source share
5 answers
 string str = "it is a \"text\"";
 string str_without_quotes = str.Replace("\"", "");

Do not try to check if it contains quotation marks, just replace them.

+5
source

To check if it contains a quote: str.Contains("\"");

To remove quotes: str.Replace("\"","");

+12
source

To delete str = str.Replace("\"", String.Empty);

+1
source

Do not forget that the good old (char) 34! It can be used instead of "\" "and @" "" too!

+1
source
bool containsQuote = str.Contains("\"");
0
source

Source: https://habr.com/ru/post/1758853/


All Articles