Getting certain rows from list of rows(C#3.0)
I have a datatable having 44 rows.
I have converted that开发者_Python百科 to list and want to take the rows from 4th row till the last(i.e. 44th).
I have the below program
IEnumerable<DataRow> lstDr = dt.AsEnumerable().Skip(4).Take(dt.Rows.Count);
But the output is Enumeration yielded no results
I am using c#3.0
Please help.
If you want to take everything from the 4th row onwards, you don't need a Take call at all, just:
IEnumerable<DataRow> lstDr = dt.AsEnumerable().Skip(4);
When you talk about "the output" what's that coming from? What do you get if you call:
Console.WriteLine(lstDr.Count());
?
How many rows are in your data table to start with?
精彩评论