Can we create multiple empty data table dynamically?

Hello All,

I want to create 10 empty DataTable dynamically.
Is there a way to create multiple empty data tables , without having to create 10 variable / argument of datatype DataTable for it ?

Thanks in advance.

Hi,

How about the following?

listDt = Enumerable.Range(0,10).Select(Function(x) New DataTable()).ToList()

or

listDt = Enumerable.Range(0,10).Select(Function(x) templateDt.Clone).ToList()

Regards,

3 Likes

As an alternate:
Enumerable.Repeat(new DataTable(), 10).toList

grafik

Hi @ppr ,

Enumerable.Repeat method duplicates its reference. So I suppose all items of the list points single datatable instance, don’t they?

Regards,

1 Like

Thank you very much for this feedback. I did document and update the post

1 Like

After creating the Data table how can I assign it ? Do I need to create 10 variables with datatype data table ?

If possible can you please send me a screenshot of solution in UiPath.

Thanks in advance.