Vb.net – How to do inline delegates in vb.net like c#


Is it possible to create an inline delegate in vb.net like you can in c#?

For example, I would like to be able to do something inline like this:

myObjects.RemoveAll(delegate (MyObject m) { return m.X >= 10; });

only in VB and without having to do something like this

myObjects.RemoveAll(AddressOf GreaterOrEqaulToTen) 

Private Function GreaterOrEqaulToTen(ByVal m as MyObject)
    If m.x >= 10 Then 
         Return true
         Return False
    End If
End Function

— edit —
I should have mentioned that I am still working in .net 2.0 so I won't be able to use lambdas.

Best Solution

myObjects.RemoveAll(Function(m As MyObject) m.X >= 10)

See Lambda Expressions on MSDN

Related Question