I have a data table .I want to convert my data table into string array.
- data table dt=new data table();
- string[] array=dt;
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 attend5days leftRegister
Amit Kumar SinghRank #562 · 4.3K reputationPosted Jan 1, 2017, 8:49 PM EST
Try this (LINQ method syntax):
or in LINQ Query syntax:
Castis required, because Columns is of type DataColumnCollection which is aIEnumerable, notIEnumerable. The other parts should be obvious.Dinesh SanthalingamRank #2,085 · 690 reputationPosted Jan 1, 2017, 9:15 PM EST
Amit Singh.
Dilip GuptaRank #2,085 · 690 reputationPosted Jan 1, 2017, 9:25 PM EST
string[] userArr = new string[dt.Rows.Count];
for( int i = 0; i < dt.Rows.Count; i++)
{
userArr[i] = dt.Rows[i][columnIndex].ToString();
}
Dinesh SanthalingamRank #2,085 · 690 reputationPosted Jan 1, 2017, 9:40 PM EST
Dilip GuptaRank #2,085 · 690 reputationPosted Jan 1, 2017, 9:55 PM EST