Abdu
Abdu

Reputation: 205

How can I avoid single quotation marks from my string

This the sample data I am trying to remove single quotes (') from:

string address="Unnamed Road, Kemerovskaya oblast', Russia, 652226 ";

I just want to remove single quotation mark from the string, for example

string resultString="Unnamed Road, Kemerovskaya oblast, Russia, 652226 ";

Upvotes: 1

Views: 120

Answers (2)

Prabhat-VS
Prabhat-VS

Reputation: 1530

try replace method,

string address="Unnamed Road, Kemerovskaya oblast', Russia, 652226 ";

resultString = address.Replace("'",string.Empty);

OR

resultString = address.Replace("'","");

Upvotes: 3

Tummala Krishna Kishore
Tummala Krishna Kishore

Reputation: 8271

You can use Replace

string address="Unnamed Road, Kemerovskaya oblast', Russia, 652226 ";

address = address.Replace("'",string.Empty);

or

address = address.Replace(@"'",string.Empty);

if you dont want to go for escape sequences to be recognized go for verbatim like this @"..."

Upvotes: 1

Related Questions