I have a datable with 50 rows and has an ID Column. I am trying to get an array that holds only the IDs like:
string [] IDs = (from row in DataTable.Rows
select row["ID"].toString()).ToArray();
Is there a way to do this. I always get the error “Could not find he implementation of the query….”
Use the
DataTableExtensions.AsEnumerablemethod by adding a reference toSystem.Data.DataSetExtensionsand ausing System.Data;Then you should be able to use the following query:If you really need an array you can use the last line above or enclose the query in parentheses and call
ToArray()as you did originally. I’m generally not a fan of the latter approach.In fluent syntax it would be: