I would like to remove "{
and replace it with {
. The following is the line of code that I'm currently using.
var MyString = DataString.Replace(@""{", "");
The following is the error message I'm getting
Please advise
Thanks
I would like to remove "{
and replace it with {
. The following is the line of code that I'm currently using.
var MyString = DataString.Replace(@""{", "");
The following is the error message I'm getting
Please advise
Thanks
You need to escape the quote that you want to replace using two quotes, so for your example:
var MyString = DataString.Replace(@"""{", "{");
Also see How to include quotes in a string for alternatives to use quotes in strings.
If you are expecting JSON
data then what you really need is a JSON Parser
for that. And if you just want to replace "{
to {
then you simply need to escape and replace the string like below:
// 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{