Converting a string of integers to an array/arraylist

G

Graeme Downes

I have a string of integer, such as the following:

"12 24 12 9 2"

and I want to convert this into an array or arraylist which will
seperate the string into an array of integers.

How do I do this
 
J

José Joye

A way to go could be to use the Split() method of the string class. This
returns an array of string where each element will contain one number
(represented as string). Then you could convert them using int.Parse() and
fill them into an array of int.

José
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top