如何避免字符串中的单引号

时间:2016-04-09 08:40:12

标签: c# asp.net

此示例数据我尝试从

中删除单引号(sed -rn ':a;N;/^([^\n]*)\n\1$/p;//ba;/^([^\n]*)(\n\1)+$/P;//ba;s/.*\n//;ba' file
'

我只想从字符串中删除单引号,例如

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

2 个答案:

答案 0 :(得分:3)

尝试替换方法,

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

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

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

答案 1 :(得分:1)

您可以使用替换

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

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

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

如果您不想要识别转义序列,请选择逐字,例如@"..."