### Question

• Hi

Given below definition of Sum function what should be the parameters provided? I appreciate not enough code is there but whatever hint I can get would be appreciated.

Thanks

Regards

Friday, March 10, 2017 3:07 AM

• Start of with a class

```Public Class Product
Public Property Name As String
Public Property Cost As Decimal
End Class```

Get the sum of cost

```Dim Products As New List(Of Product) From
{
New Product With {.Name = "Item1", .Cost = 12D},
New Product With {.Name = "Item2", .Cost = 10D}
}
Dim CostSum = Products.Sum(Function(p) p.Cost)```
CostSum = 22

Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator

Friday, March 10, 2017 3:35 AM
• Hi

Given below definition of Sum function what should be the parameters provided? I appreciate not enough code is there but whatever hint I can get would be appreciated.

Thanks

Regards

The red box over the tooltip contains your hint...

You need to provide a function which takes an instance of tblEventSStaffRequired and returns a Decimal value.  Karen has provided an example of what such a function might look like.

Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

• Marked as answer by Sunday, March 12, 2017 2:11 PM
Friday, March 10, 2017 1:06 PM

### All replies

• Start of with a class

```Public Class Product
Public Property Name As String
Public Property Cost As Decimal
End Class```

Get the sum of cost

```Dim Products As New List(Of Product) From
{
New Product With {.Name = "Item1", .Cost = 12D},
New Product With {.Name = "Item2", .Cost = 10D}
}
Dim CostSum = Products.Sum(Function(p) p.Cost)```
CostSum = 22

Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator

Friday, March 10, 2017 3:35 AM
• Hi

Given below definition of Sum function what should be the parameters provided? I appreciate not enough code is there but whatever hint I can get would be appreciated.

Thanks

Regards

The red box over the tooltip contains your hint...

You need to provide a function which takes an instance of tblEventSStaffRequired and returns a Decimal value.  Karen has provided an example of what such a function might look like.

Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

• Marked as answer by Sunday, March 12, 2017 2:11 PM
Friday, March 10, 2017 1:06 PM