Data Table Headers

Hello,

Please provide the solution for how to get data table headers or Column names as array or item array

Thanks in advance

Hi @RVK

Try this
(From dc In dt.Columns.Cast(Of System.Data.DataColumn) Select dc.ColumnName).ToArray()

dt is your datatable

cheers

Hi @RVK ,

An Alternate using Method Syntax :

DT.Columns.Cast(Of DataColumn).Select(Function(x)x.ColumnName).ToArray

Hi @RVK

You can try with this expression

(from P in dt.Columns.Cast(of System.Data.DataColumn)Select P.ColumnName).ToArray 

Regards
Gokul

Thank you
@Anil_G
@supermanPunch
@Gokul001
For quick response

1 Like

Very usefull, thanks

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