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