-
Array problem
I have the following code:
Code:
Dim aaa As New List(Of String())
Dim dt as Datatable
How can I loop through the datatable and add into the list?Something like this:
Code:
aaa.add(new string() {Row1,Row2,Row3 etc})
The result should be in one row of the list only.
-
Re: Array problem
First: I think you want
Code:
Dim aaa As New List(Of String)
then something like this:
Code:
for each r in dt.rows
aaa.add(r.field) ' where field is a string
next
-
Re: Array problem
It sounds like the OP is saying that he wants all the rows from the datatable to be in a single string (list row)
If so then that would require looping through all the rows, appending them to a string then add the completed string to the list.
-
Re: Array problem
If you want a list of array of string then keep the Dim the same. You will then need to Dim a new String(), somehow set the dimension (maybe ReDim to dt.rows.count) then Add it to aaa. Once you have your single element in aaa then loop through the dt and add it to the first element:
Code:
dim i as new integer
for each r in dt.rows
aaa(0)(i)=r.field
i+=1
next