Imports System.Globalization Public Class Sheet Public Shared Sheets As New Dictionary(Of Integer, Sheet) Private Property Sheet As Integer Public Property Members As List(Of Member) Public Sub New(sheet As Integer) Members = New List(Of Member) Me.Sheet = sheet End Sub ''' <summary> ''' Generates the total weight of a sheet when the type of member ''' is passed to the function ''' </summary> ''' <param name="memberType">The type of member on a sheet, i.e. "Ladder", "Stair", etc</param> ''' <returns>Returns as a double the total weight of all members on a sheet for the MemberType</returns> ''' <remarks></remarks> Public Shared Function WeightByType(memberType As String) As Decimal Dim subset = Sheets.Where( Function(kvp As KeyValuePair(Of Integer, Sheet)) _ kvp.Value.Members.Count(Function(m) m.MemberType = memberType) > 0) subset.ToList().ForEach( Sub(kvp As KeyValuePair(Of Integer, Sheet)) _ WeightByType += (kvp.Value.Members.Sum( Function(m As Member) _ Convert.ToDecimal(m.TotalWeight, CultureInfo.InvariantCulture)))) End Function End Class
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.