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

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -