简体   繁体   中英

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 ";

try replace method,

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

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

OR

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

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 @"..."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM