I am doing this, like in this answer :
string test = "test\"test";
test = test.Replace("\\\"", "");
but the result is still test = "test\"test"
.
The result shoud be test = "testtest"
, Why my replace does not work ?
I am doing this, like in this answer :
string test = "test\"test";
test = test.Replace("\\\"", "");
but the result is still test = "test\"test"
.
The result shoud be test = "testtest"
, Why my replace does not work ?
Because your string is actually test"test
not test\"test
. The backslash is used to escape double quote, it's not in the actual string.
Try using a verbatim string:
string test = @"test\""test"; // equivalent to test\\\"test