Hi I am trying to use c# to generate a comma separated string of columns for all the columns in a data table. I see commonly used stuff on the forum, but I cant seem to find something that fits this request.
Can someone help me out with what this would look like?
Anil_G
(Anil Gorthi)
March 17, 2023, 2:24pm
2
@Cushing_Gregory
Please try this
String.Join(",",dt.Columns.Cast<DataColumn>().Select(x => x.ColumnName).ToArray())
cheers
Anil_G
(Anil Gorthi)
March 17, 2023, 2:37pm
4
@Cushing_Gregory
Please change dt as per your datatable name …May be it is bulkdt or testdt for you
cheers
It is using the correct dt which is an argument.
Cushing_Gregory:
image1920×1080 332 KB
Hi @Cushing_Gregory ,
From the above screenshot we see that it is VB project and not C#.
Try the below with the similarity as in the above post :
String.Join(",",DT.Columns.Cast(Of DataColumn).Select(Function(x)x.ColumnName).ToArray)
Appreciate the help, my eyes are rough this morning. Makes sense the invoke code c# code block ran the code. I will test out and report back.
1 Like