Recently one of my friend was needed only first three rows of data table and so he asked me and I have multiple solutions for that. So thought it would be great idea to share with you guys. There are two ways to solve this problem.
- With normal for loop
- With lamda expression and linq
Following is code from where we can get 3 rows of data table.
private DataTable GetFirst3RowViaFor(DataTable dataTable) { DataTable newDataTable = dataTable.Clone(); for(int i=0;i