A better way of handling the below program(may be with Take/Skip/TakeWhile.. or anything better)

Posted by Newbie on Stack Overflow See other posts from Stack Overflow or by Newbie
Published on 2010-06-14T08:48:49Z Indexed on 2010/06/14 8:52 UTC
Read the original article Hit count: 110

Filed under:

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.

© Stack Overflow or respective owner

Related posts about c#3.0