Convert DataTable Column to String Array

Hi,

I am attempting to convert a DataTable Column into a String Array but find no easy way to do this.

Would anyone have suggestions?

Thanks in advance!

1 Like

Hi,

Try like this,

List(of string) = (From row in dt.AsEnumerable() Select Convert.Tostring(row(‚ÄúColumnName‚ÄĚ))).ToList()

replace the ‚ÄúColumnName‚ÄĚ with your datatable column name or use index of the column.

8 Likes

Thank you sarathi125 for your response!

Your suggestion worked nicely. The only thing I changed was ToList() --> ToArray()

2 Likes