title: Getting a count of rows in a datatable that meet certain criteria
body: <p>I have a datatable, dtFoo, and would like to get a count of the rows that meet a certain criteria.</p>
  
  <p>EDIT: This data is not stored in a database, so using SQL is not an option.</p>
  
  <p>In the past, I've used the following two methods to accomplish this:</p>
  
  <p><strong>Method 1</strong></p>
  
  <pre><code>int numberOfRecords = 0;
  DataRow[] rows;
  
  rows = dtFoo.Select("IsActive = 'Y'");
  numberOfRecords = rows.Length;
  
  Console.WriteLine("Count: " + numberOfRecords.ToString());
  </code></pre>
  
  <p><strong>Method 2</strong></p>
  
  <pre><code>int numberOfRecords = 0;
  
  foreach (DataRow row in dtFoo.Rows)
  {
      if (row["IsActive"].ToString() == "Y")
      {
          numberOfRecords++;
      }
  }
  
  Console.WriteLine("Count: " + numberOfRecords.ToString());
  </code></pre>
  
  <p>My shop is trying to standardize on a few things and this is one issue that has come up.  I'm wondering which of these methods is best in terms of performance (and why!), as well as which is most commonly used.</p>
  
  <p>Also, are there better ways to achieve the desired results?</p>