0
這裏是我的字符串我從csv了:用逗號,但沒有分裂雙重價值分開分割字符串
string input = "Volume,447,\"4,325\",142,144";
什麼,我想在我的陣列線:
447
4,325
142
144
我的嘗試:
string[] volumes;
if (input.Contains(",\"")) // if they're all double value, it works
volumes = input.Split(new[] {",\""}, StringSplitOptions.None);
else
volumes= input.Split(','); // if they're all integer value it works
else
// what to do if they have both double and integer?
聽起來像你可以用一個體面的CSV解析器...我不會打擾試圖推出自己的。 –
如果你從JSON得到這個字符串,你爲什麼不完全反序列化它,而不是解析字符串?或者,也許它會更簡單,如果你爲我們提供原始的JSON – Uriil
@Uriil omg,對不起,我的字符串來自csv,而不是來自json – Gui