Easiest way to parse a comma delimited string to some kind of object I can loop through to access the individual values?

前端 未结 7 678
予麋鹿
予麋鹿 2020-11-28 06:57

What is the easiest way to parse a comma delimited string list of values into some kind of object that I can loop through, so that I can access the individual values easily?

7条回答
  •  借酒劲吻你
    2020-11-28 07:19

       var stringToSplit = "0, 10, 20, 30, 100, 200";
    

        // To parse your string 
        var elements = test.Split(new[]
        { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
    

        // To Loop through
        foreach (string items in elements)
        {
           // enjoy
        }
    

提交回复
热议问题