LINQ query to sum Price values stored in datatable

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.
1 Like