答案 0 :(得分:1)
您需要使用两个引号对要替换的引号进行转义,因此对于您的示例:
var MyString = DataString.Replace(@"""{", "{");
有关在字符串中使用引号的替代方法,请参见How to include quotes in a string。
答案 1 :(得分:1)
如果您希望获得JSON
数据,那么您真正需要的是JSON Parser
。而且,如果您只想将"{
替换为{
,则只需转义并替换如下字符串:
// Suppose the variable named str has a value of Hello"{ wrapped in double quotes
var strReplaced = str.Replace("\"{", "{");
Console.WriteLine($"strReplaced: {strReplaced}");
// This will result in strReplaced: Hello{