views:

467

answers:

1

In C# i just put the method in the parentheses that i want to run on each row of the collection, but it isn't working in VB.NET.

ex:

SubSonic.PartCollection Parts;
...
Parts.ForEach(TestMethod);

I've tried this in VB.Net, but it's not compiling, and i'm not quite sure what I'm missing.

Dim Parts as SubSonic.PartCollection
...
parts.ForEach(TestMethod)

If i break it apart and do it manually it works:

for each p as SubSonic.Part in Parts
    TestMethod(p)
next

I'm just trying to clean things up a little

Thanks Tony W

+3  A: 

Try this:

parts.ForEach(AddressOf TestMethod)

In fact the ForEach method accepts a delegate of type Action<T> and you should use the AddressOf to pass a pointer to a given method in VB.NET

Darin Dimitrov
Awesome, that was itThanksTony W
Tony W