I am reading a data file that has a string of data (numbers separated by commas) like this 101,214,345,423,5,6,7
I have been parsing this string to fill an array of Ints and I was wondering if there was a way to do this:
B4X:
Dim StringArray As String = "1,2,3,4,5,6,7,8,9" ' Read the string of data into a string
Dim IntArray() As Int
IntArray = Array As Int(StringArray) ' IS THERE ANY Way to tell the complier I want what is in the string not the string?
Normally I would manually init an array with something like this IntArray = Array as Int(1, 2, 3, 4, 5)
Which is pretty much the same as what is inside my string.
This would really speed the code up if I did not have to parse the individual entries.
Dim StringArray As String = "1,2,3,4,5,6,7,8,9"
Dim strArray() As String =Regex.Split(",",StringArray)
Log(strArray(6)) 'displays 7
Log (strArray(7)/strArray(1)) 'displays 4
or this:
B4X:
Dim StringArray As String = "1,2,3,4,5,6,7,8,9"
Dim strArray() As String =Regex.Split(",",StringArray)
Dim intArray(strArray.Length) As Int
For i = 0 To strArray.Length-1
intArray(i)=strArray(i)
Next
Log(intArray(6)) 'displays 7
Log (intArray(7)/strArray(1)) 'displays 4