Hello!
I have 2 arrays:
arr1 = {apple, banana, orange}
arr2 = {1,2,3}
I need to save the values to a datatable.
DT = {fruit, amount}
I usually use this syntax to convert an array to DT, any way if I can do this in 2 array and save them to a DT with 2 columns?
arr1.Select(Function (x) DT.Rows.Add(New Object(){x})).CopyToDataTable
Hi!
Create one build dataTable columnNames-> fruit, amount->Output Dt_out
Take one for each row mention Arr1
Take one more for each row Arr2
Now take one add data row
in array of row mention like this
{item1,item2}
DataTable Dt_Out
Regards,
NaNi
Yoichi
(Yoichi)
3
Hi,
Hope the following helps you.
dt = arr1.Select(Function (x,i) dt.Rows.Add(New Object(){x,arr2(i)})).CopyToDataTable
OR
dt = arr1.Zip(arr2,Function (x,y) dt.Rows.Add(New Object(){x,y})).CopyToDataTable
Regards,
1 Like
Thank you! This is what I am looking for
1 Like
system
(system)
Closed
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.