【发布时间】:2021-08-05 00:01:12
【问题描述】:
我试图遍历一个匿名类型集合但得到一个 System.MissingMemberException H结果=0x80131512 消息=重载解析失败,因为没有可访问的“ForEach”接受此数量的参数。 并且无法确定原因。我成功使用 For Each 但无法使用 Lambda 表达式。
Dim car As Object = {(New With {Key .Model = "Buick", .Color = "Blue"}),
(New With {Key .Model = "Volvo", .Color = "Green"}),
(New With {Key .Model = "Jeep", .Color = "Red"})}
For Each item In car
If item.Color = "Blue" Then Debug.Print(String.Format("{0} {1}", item.Model, item.Color))
Next
car.ForEach(Sub(x)
Debug.Print(String.Format("[0} {1}", x.model, x.color))
End Sub)
【问题讨论】: