How to split a data table using a row index

Hi,

I want to split a data table in two, based on the row index. Initially I used a for each row with a if inside it, but it took too long. Do you know another way that can improve efficiency?

Many thanks,
Rodrigo

Hi ,
It can be split using the Linq

  1. Take first n rows by using dataTable.AsEnumerable().Take(2).CopyToDataTable()
  2. Then you can take remaining by skip n rows
    dataTable.AsEnumerable().skip(2).Take(2).CopyToDataTable()
1 Like