A better way of handling the below program(may be with Take/Skip/TakeWhile.. or anything better)
- by Newbie
I have a data table which has only one row. But it is having 44 columns. My task is to get the columns from the 4th row till the end.
Henceforth, I have done the below program that suits my requirement.
(kindly note that dt is the datatable)
List<decimal> lstDr = new List<decimal>();
Enumerable.Range(0, dt.Columns.Count).ToList().ForEach(i =>
{
if (i > 3)
lstDr.Add(Convert.ToDecimal(dt.Rows[0][i]));
}
);
There is nothing harm in the program. Works fine.
But I feel that there may be a better way of handimg the program may be with Skip ot Take or TakeWhile or anyother stuff.
I am looking for a better solution that the one I implemented.
Is it possible?
I am using c#3.0
Thanks.