user384080
user384080

Reputation: 4692

Datatable select by row range c#

Does anyone know how to select datatable by row range? say if I need to pull out records in datatable from row #20 - #50.

Upvotes: 9

Views: 15108

Answers (1)

Jeff Ogata
Jeff Ogata

Reputation: 57793

If you want to include rows 20 and 50, I think this will work:

var rows = (from r in table.AsEnumerable()
            select r).Skip(19).Take(31);

update:

or more succinctly:

var rows = table.AsEnumerable().Skip(19).Take(31);

Upvotes: 20

Related Questions