Hello
How to convert DataTable to string array?
there are only one column in datatable.
Thank in advance.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Feb 7, 2014, 5:37 AM EST
string[] array = (from DataRow dr in dt.Rows select dr[0].ToString()).ToArray();
Abhishek KumarRank #510 · 4.8K reputationPosted Feb 11, 2014, 6:47 AM EST
Hi,
DataTable dt=new DataTable ();
string[] array = dt("db_Column"))
.AsEnumerable()
.Select(row => row.Field
.ToArray();
Hope this will work.
Thanks.