Add List to datatable

I am trying to add a list, of type decimal, to a datatable however I am unable to use the Add Data Row given that I have gotten an error when trying to convert my list into an array and I do not know how to change a list into a datarow object.

List to Array Error:

Only way i could think of is manually entering each value using a for each row which is ok for my situation given that I only need two rows in my datatable.


Can you try the following expression?

reportTotals.Select(Function(n) cobj(n)).ToArray()



Hi @Nelson.R ,
You would require to Convert the Array of Decimals into an Object Array. You Could do it in the Below way by performing a Cast :

reportTotals.Cast(Of Object).ToArray


1 Like

Hi @Yoichi and @supermanPunch

Both options worked thank you. Just had some errors to fix in a process before this so took longer for me to test it.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.