user3654442 user3654442 - 10 months ago 46 Question

Converting strings into an int array in visual basic?

Lets say I have a string like this:


How can I make a function in VB to turn that into an array of ints?

Answer Source

First split the string with the comma as separator and then convert each element in that resulting array into integer.

Dim ints = Array.ConvertAll("1,2,5,8".Split(","c), AddressOf Convert.ToInt32)