【发布时间】:2012-07-06 14:46:47
【问题描述】:
我有一个类Parent,它的属性为Items,即List(of Child)
如果我使用此代码
Parallel.ForEach()(parent.Items,
Sub(item)
item.DoSomething()
End Sub)
我收到编译器警告No overload for method ForEach() accepts this count of arguments
如果我将代码更改为
Parallel.ForEach(of Child)(parent.Items,
Sub(item)
item.DoSomething()
End Sub)
它有效。
但是,在c#中我可以写
Parellel.ForEach(parent.Items, item =>
{
item.DoSomething();
});
为什么 VB 在这种情况下不推断?
【问题讨论】:
-
您能否更具体地说明参数类型,使用
Sub(item As Child)?
标签: c# vb.net generics task-parallel-library type-inference