C# DataTable select method

Author: | Categories: Programming No Comments

DataTable has a Select method. This method receives a string expression that specifies what rows you want to handle.

Selection based on a string expression


DataRow[] result = table.Select("Size >= 230 AND Sex = 'm'");

Selection based on DateTime


DataRow[] result = table.Select("Date > #6/1/2001#");

Number of records for a particular criteria


int numberOfRecords = table.Select("IsActive = 'Y'").Length;

Leave a Reply

Your email address will not be published.