I have a class Parent which has as property Items that is a List(of Child)
If I use this code
Parallel.ForEach()(parent.Items,
Sub(item)
item.DoSomething()
End Sub)
I get a compiler warning No overload for method ForEach() accepts this count of arguments
If I change the code to
Parallel.ForEach(of Child)(parent.Items,
Sub(item)
item.DoSomething()
End Sub)
it works.
However, in c# I can just write
Parellel.ForEach(parent.Items, item =>
{
item.DoSomething();
});
Why does VB not infer in this case?
In your first VB example you have an extra set of parentheses so you are calling .ForEach wih no parameters. Remove them and it will work: