I’m trying to replace the classic For Each loop with the LINQ ForEach extension in VB.NET…
Dim singles As New List(Of Single)(someSingleList)
Dim integers As New List(Of Integer)
For Each singleValue In singles
integers.Add(CInt(Math.Round(singleValue)))
Next singleValue
Maybe something like this?
singles.ForEach(Function(s As [Single]) Do ???
How can I correctly do this using anonymous methods (i.e. without declare a new function)?
Try this:
You need a
Subhere, because the body of yourFor Eachloop doesn’t return a value.