In C#, is it possible to get all values of a particular column from all rows of a DataSet with a simple instruction (no LINQ, no For cicle)?
As far as I know there's no direct way to get those; but the for-loop is pretty straightforward and obviously won't be more resource-intensive than anything else.
In addition to Utaal's answer, you can possibly populate a new DataTable object with the results of a query that selects only one column from your original data source, assuming it's an RDBMS. This has the advantage of letting you specify things that are easy to express in code but easy to express in SQL like DISTINCT
queries.
Only by iterating over the rows, as Utaal noted in this answer.
You might expect that the DataTable.DefaultView.RowFilter
would support grouping, but it does not (it mainly offers the equivalent functionality of a Where
clause, with some basic aggregations - though not simple grouping).