You can try
using System.Linq; ... ... ... foreach (DataRow dr in rows.Cast<DataRow>().Take(50)) { }
Note that you must call Cast<DataRow>() to convert the DataRowCollection to IEnumerable<DataRow> , which allows you to use the Take() extension method.
Adam ralph
source share