2,892 questions
Check this query:
Dim areas As Areas = . . .
Dim sum = areas.SelectMany(Function(a) a.Items).Sum(Function(i) i.Total)
It assumes that the objects are not Nothing.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hallo,
I am trying to get a sum of all "Total" form the object Item. I have list called "Areas" and it has the custom object "Items", it is the list of Item. and the Item has a property "Total"
I want to sum all the total from Areas. how can i do it?
Public Class AreaObj
Public property Items as Items
End class
Public Class Areas
Inherits System.ComponentModel.BindingList(Of AreaObj)
End class
Public Class Item
Public property Total as integer
End class
Public Class Items
Inherits System.ComponentModel.BindingList(Of Item)
End class
Thanks
Check this query:
Dim areas As Areas = . . .
Dim sum = areas.SelectMany(Function(a) a.Items).Sum(Function(i) i.Total)
It assumes that the objects are not Nothing.
thanks Viorel. It worked.