Convert DataTable Column to String Array

studio

#1

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!


#2

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.


#3

Thank you sarathi125 for your response!

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