'Select the max,min of nested lists vb.net
I have these objects
Public Class Class1
Public Property Type As String
Public Property SpecLimits As Limits
End Class
Public Class Limits
Public Property MinValue As Double?
Public Property MaxValue As Double?
End Class
I can have more Type-s with their Speclimits values. I need to find the maximum of MaxValue. I can make it with a for each to check every time which number is bigger, but I thought maybe their is some linq with what this could be achievable.
I found something like this in c#
var maxItem = emplist
.Select((emp, index) => new
{
maxProject = emp.project
.Select((proj, pIndex) => new{ proj, pIndex })
.OrderByDescending(x => x.proj.ID)
.First(),
emp, index
})
.OrderByDescending(x => x.maxProject.proj.ID)
.First();
but I can't translate it to vb.net
Any help is appreciated!
Solution 1:[1]
I guess you want something like this:
Dim minValue As Double = list.Min(Function(x) x.SpecLimits.MinValue)
Dim maxValue As Double = list.Max(Function(x) x.SpecLimits.MaxValue)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
