【发布时间】:2019-02-05 09:47:16
【问题描述】:
我想使用“,”分隔符将字符串转换为字符串数组。我在下面使用这段代码,但是当字符串有一个&符号时会切断字符串的结尾。
string example = "one,two,three&four";
return new []{ example };
//结果["one,two,three"]
我怎样才能得到结果:["one","two","three&four"]?
【问题讨论】:
标签: c#
我想使用“,”分隔符将字符串转换为字符串数组。我在下面使用这段代码,但是当字符串有一个&符号时会切断字符串的结尾。
string example = "one,two,three&four";
return new []{ example };
//结果["one,two,three"]
我怎样才能得到结果:["one","two","three&four"]?
【问题讨论】:
标签: c#
您应该使用Split 而不是Join。
请试试这个:
string[] result = example.Split(',');
【讨论】: