Is both approach same ?
- by Harikrishna
I have one datatable which is not bindided and records are coming from the file by parsing it in the datatable dynamically every time. Now there is three columns in the datatable Marks1,Marks2 and FinalMarks. And their types is decimal. Now for making addition of columns Marks1 and Marks2 's records and store it into FinalMarks column,For that what I do is :
datatableResult.Columns["FinalMarks"].Expression="Marks1+Marks2";
It's works properly.
It can be done in other way also is
foreach (DataRow r in datatableResult.Rows)
{
r["FinalMarks"]=Convert.ToDecimal(r["Marks1"])+Convert.ToDecimal(r["Marks2"]);
}
Now I don't know that which is the best way to do this means performance wise. Is first approach same as second approach in background means is both approach same or what?