【问题标题】:Create string[] from string with ampersand [duplicate]使用&符号从字符串创建字符串[] [重复]
【发布时间】:2019-02-05 09:47:16
【问题描述】:

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

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

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

我怎样才能得到结果:["one","two","three&four"]

【问题讨论】:

    标签: c#


    【解决方案1】:

    您应该使用Split 而不是Join

    请试试这个:

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

    【讨论】:

      猜你喜欢
      • 2015-05-28
      • 1970-01-01
      • 2013-07-24
      • 1970-01-01
      • 1970-01-01
      • 2012-11-27
      • 1970-01-01
      • 2014-10-24
      • 2012-06-15
      相关资源
      最近更新 更多