string.Replace(@"",@"") doesn't w

本文关键字:quot doesn Replace string | 更新日期: 2023-09-27 17:50:50

我有字符串从配置中获取。这是"DONGHOANG '黄平君"我试着用'代替'',但它不起作用?这是我的代码?有没有解决办法

string linked_sv_name =
    "[" + config.AppSettings.Settings[cbbkho.SelectedValue.ToString()].Value + "]";
linked_sv_name = linked_sv_name.Replace(@"''", @"'");

string.Replace(@"",@"") doesn't w

不应该将2个斜杠替换为1,而应该将1个斜杠替换为2:

string linked_sv_name = "[" + config.AppSettings.Settings[cbbkho.SelectedValue.ToString()].Value + "]";
linked_sv_name = linked_sv_name.Replace(@"'", @"''");

当传递给sqlCommand时,双斜杠将变成1斜杠