我试图用VB.NET中的LINQ ForEach扩展替代经典的For Each循环
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
也许这样吗?
singles.ForEach(Function(s As [Single]) Do ???
尝试这个:
原文链接:https://www.f2er.com/vb/255656.htmlsingles.ForEach(Sub(s As [Single]) integers.Add(CInt(Math.Round(s))))
您需要一个Sub,因为您的For Each循环的正文不返回值.