用&符从字符串创建string []

时间:2018-08-30 12:33:09

标签: c#

我想使用“,”分隔符将字符串转换为字符串数组。我在下面使用此代码,但是当字符串中有一个&符时,它会切断字符串的结尾。

string example = "one,two,three&four";
return new []{ example };

//结果["one,two,three"]

如何获取结果:["one","two","three&four"]

1 个答案:

答案 0 :(得分:1)

您应该使用Split而不是Join

请尝试以下操作:

string[] result = example.Split(',');