【C#】カンマで区切りのStringをリストに入れ直す
2021-02-23 2021-02-27
Linqを使って行う。よく忘れるのでメモ。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
string s = "1.00,1.20,1.50"; //リスト List<float> data = s .Split(',') .ToList() .ConvertAll(x => float.Parse(x)); //配列 float[] data = s .Split(',') .Select(x => float.Parse(x)) .ToArray(); |