I have a data table and a column contains int values. I have not specified the column with any datatype. When I perform the following.
object sum = dttest.Co
You can use LINQ to Datatable:
var result = dttest.AsEnumerable() .Sum(x => Convert.ToInt32(x["Value"]));
Example how to Sum for specific name:
Sum
var result = dttest.AsEnumerable() .Where(r => r.Field("Name") == "FilterName") .Sum(x => Convert.ToInt32(x["Value"]));