I have a datatable
which holds some Id. I want to extract those Id's with comma seperated values. What I tried is:
With LINQ
int [] strGoalIds = (from Task in dtActionItems.AsEnumerable()
select Task.Field<int>("TaskEntityId")).ToArray();
string strGoalTagIds = "";
if (strGoalIds.Count() > 0)
{
strGoalTagIds = string.Join(",", strGoalIds );
}
WITH For Loop
string strGoalIds = "";
for (int i = 0; i < dtActionItems.Rows.Count; i++)
{
strGoalIds = strGoalIds + "," + dtActionItems.Rows[i]["TaskEntityId"].ToString();
}
Can anyone tell me which is the best way to proceed.