Use skip() and Take() method in linq

Hi Guys
I need you help to understand in which scenario we can use skip() and Take() method togather
like below query use to split excel into chunks
ExampleExcel.zip (235.0 KB)
Split_Excel_Files.xaml (18.1 KB)

dt_Input.AsEnumerable.Skip(int_Boundry_Start_Row-1).Take(int_Split_Row_Count).CopyToDataTable

Have a look here:

And have some practicals here:

Can anyone help me on this topic

HI,

How about the following?

Enumerable.Range(0,(dt.Rows.Count \ chunkSize)+1).Select(Function(i) dt.AsEnumerable.Skip(i*chunkSize).Take(ChunkSize).CopyToDataTable).ToArray

Sample20221108-4.zip (132.8 KB)

Regards,

1 Like