c# - converting a string to a list of integers -
i have visual studio 2008 c#.net 3.5 application have string list of numbers separated semicolon.
string num_list = "1;2;3;4;201;2099;84"
i convert list<int>
. there easier way this?
list<int> foo = new list<int>(); foreach (string num in num_list.split(';')) foo.add(convert.toint32(num));
thanks, paulh
list<int> foo = num_list.split(';').select(num => convert.toint32(num)).tolist();
Comments
Post a Comment