Hi Team,
I need a help where I’m currently dealing with datatables and I have one column named Price and wanted sum up the values in it.
Please help
Hi Team,
I need a help where I’m currently dealing with datatables and I have one column named Price and wanted sum up the values in it.
Please help
Try this LINQ
dbltotalPrice = dt.AsEnumerable().Sum(Function(row) Convert.ToDouble(row("Price")))
Hi @Nisha_K21 ,
Assuming column Price is of the type double
totalPrice = yourDataTable.AsEnumerable().Sum(Function(row) row.Field(Of Double)("Price"))
Explanation
yourDataTable
: Replace this with the name of your DataTable
variable.row.Field(Of Double)("Price")
: Accesses each value in the "Price"
column as a Double
.totalPrice
: This should be a variable of type Double
to store the sum.Thank you @ashokkarale and @Manisha_Ravindra
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.