DataTable Select Method

09.12.07

The Select method is really handy for filtering and sorting the rows you need from a strongly typed dataTable. It has 3 overloads Select() for returning all the rows as an array select(stringFilter) for returning the rows with out sorting and Select(stringFilter,stringSort) for returning rows with sorting. Here is quick way to fire everyone with the first name of bob in your employee management application.

var people = peopleDataTable.Select(
                                    "FirstName = bob AND Fired = 0",
                                    "LastName"
                                    ) as EmployeeDataSet.PeopleRow[];
foreach (EmployeeDataSet.PeopleRow person in people)
{
     person.Fired = true;
}


more Info:
MSDN
even better example

C#