Si puo' fare anche con una select sul datatable.
codice:
class Program
{
static void Main()
{
// Create a table of 5 different players.
// ... Store their size and team.
DataTable table = new DataTable("Players");
table.Columns.Add(new DataColumn("Size", typeof(int)));
table.Columns.Add(new DataColumn("Team", typeof(char)));
table.Rows.Add(100, 'a');
table.Rows.Add(235, 'a');
table.Rows.Add(250, 'b');
table.Rows.Add(310, 'b');
table.Rows.Add(150, 'b');
// Search for players above a certain size.
// ... Require certain team.
DataRow[] result = table.Select("Size >= 230 AND Team = 'b'");
foreach (DataRow row in result)
{
Console.WriteLine("{0}, {1}", row[0], row[1]);
}
}
}
fonte:
https://www.dotnetperls.com/datatable-select