I have a datatable with few rows each row has few columns.
I want to create an arraylist that countain all row as a string
so each array item look like this {1
Here is a solution that actually works.
ArrayList rows = new ArrayList();
foreach (DataRow dataRow in myDataTable.Rows)
rows.Add(string.Join(";", dataRow.ItemArray.Select(item => item.ToString())));
However, I feel I should point out that it is unwise to use the obsolete ArrayList
. Use List
instead, since the rows are strings:
List rows = new List();
The rest of the code is the same.