Convert string array to datarow array
How can i convert string array to an array of datarow can any one help me please.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
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
VulpesRank #55 · 29.2K reputationPosted Apr 12, 2011, 2:26 AM EDT
// 'strings' is the string array and 'table' is the DataTable
DataRow[] rows = new DataRow[strings.Length];
for(int i = 0; i < strings.Length; i++)
{
rows[i] = table.NewRow();
// assuming each element of the string array contains comma-separated row values
rows[i].ItemArray = strings[i].Split(',');
table.Rows.Add(rows[i]); // if needed at this stage
}