这个问题在这里已有答案:
我正在研究一个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中查看结果。