I know @bharat asked for a solution using LINQ, but mainly for myself I wanted to compare @Kelsey's solution to the old fashioned way of doing this:
List<Obj> list = new List<Obj>();
foreach (DataRow r in yourDataSet.Tables[0].Rows)
{
Obj obj = new Obj();
obj.Column1 = r["Column1"];
obj.Column2 = r["Column2"];
obj.Column3 = r["Column3"];
obj.Column4 = r["Column4"];
obj.Column5 = r["Column5"];
obj.Column6 = r["Column6"];
obj.Column7 = r["Column7"];
obj.Column8 = r["Column8"];
obj.Column9 = r["Column9"];
obj.Column10 = r["Column10"];
list.Add(obj);
}
Or via constructor:
List<Obj> list = new List<Obj>();
foreach (DataRow r in yourDataSet.Tables[0].Rows)
{
Obj obj = new Obj(r["Column1"], r["Column2"], r["Column3"], r["Column4"], r["Column5"],r["Column6"], r["Column7"], r["Column8"], r["Column9"],r["Column10"]);
list.Add(obj);
}
I intentionally left off .ToString()
because I think using it depends on the situation.