You can get the values from a named column in the
DataTable
using a single line of code in LINQ.
Steps:
- Convert the
DataTable
object to Enumerable()
.
- Apply the
select
clause with the column name as field name. - Cast it to a
string
array.
string[] strSummCities = dtTemp1.AsEnumerable().Select(s => s.Field<string>("City")).ToArray<string>();