C # Convert 2D array to dataset / datatable
3 answers
Please take a look at the following article
Convert Excel Table to DataSet, DataTable and Multidimensional Array
+3
source to share
You can create dataset / datatable in code: http://msdn.microsoft.com/en-us/library/system.data.datatable.aspx
From there, you will loop through the array and fill the rows and their columns with information about the array.
+1
source to share
The option given by mr.phoenix should work. If you are stuck with working with arrays ... here is some pseudocode.
var sample = {{0, 1}, {2, 3}, {4, 5}, {6, 7}, {8, 9}};
var table = new DataTable("SampleTable");
// iteration logic/loops for the array
{
var newRow = table.NewRow();
newRow["Col1"] = sample[i,j0]; // like sample [0,0]
newRow["Col2"] = sample[i,j1]; // like sample [0,1]
table.Add(newRow);
}
+1
source to share