c# 如何替换字符串中的反斜杠?

c# How can i replace backslash in a string?

我正在做一个 c# 项目,有一些像这样的字符串

第一个字符串

"[\"2018\/02\/12\",[\"Test1\",\"Test2\",\"Test3\",\"Test4\"]]"

但是这种字符串格式不适合我的应用。我想将第一个字符串更改为:

第二个字符串

2018-02-12,"Test1","Test2","Test3","Test4"

我已经完成了一些,但是我在获取反斜杠时遇到了问题。实际上反斜杠没有改变。

我的代码:

string MyString = "[\"2018\/02\/12\",[\"Test1\",\"Test2\",\"Test3\",\"Test4\"]]";
MyString = MyString.Replace("[", "").Replace("]", "").Replace("\", "");

如何获取第二个字符串?

使用以下代码:

MyString.Replace("[", string.Empty).Replace("]", string.Empty).Replace("\", string.Empty).Replace(@"\", string.Empty).Replace("/", "-");

并在 Text Visualizer 中查看结果。