How to get list of one column values from DataTable?
You can use Linq to DataTable: var ids = dt.AsEnumerable().Select(r => r.Field<int>(“id”)).ToList(); UPDATE: Without Linq List<int> ids = new List<int>(dt.Rows.Count); foreach(DataRow row in dt.Rows) ids.Add((int)row[“id”]); Note for efficiency it’s better to use row[index] instead of row[columnName]. First one just gets column by index from columns array. Latter gets column index from internal dictionary which maps … Read more