Imports System.Collections.Generic
Public Property Id As Integer
Public Property Total As Double
Public Sub New(ByVal idValue As Integer)
Total = New Random(id * 10).NextDouble() * 10
Public Overrides Function ToString() As String
Return $"Item {Id} total: {Total}"
Dim items As List(Of CartItem) = New List(Of CartItem)()
For i As Integer = 1 To 10
Dim item = New CartItem(i)
Console.WriteLine($"Added {item.ToString()}")
Console.WriteLine($"Sum of all items: {GetSum(items)}")
Private Shared Function GetSum(ByVal items As List(Of CartItem)) As Double
Return (from item as CartItem in items Select item.Total).Sum()