89

I am working on a VB.net project now. I am new to VB.Net LINQ and would like to know the Lambda equivalent of

var _new = orders.Select(x => x.items > 0);

in VB.Net.

Someone please suggest!

2

1 Answer 1

118

The lambda syntax isn't that much different than creating a regular delegate.

If creating a lambda which has a return value, use Function. Otherwise if you're creating one that doesn't, use Sub.

Dim _new = orders.Select(Function(x) x.Items > 0)

Dim action As Action(Of Item) = Sub(x) Console.WriteLine(x.Items)
Sign up to request clarification or add additional context in comments.

2 Comments

It looks different from a standard delegate, since in this case there is no return statement, and the value returned is the value of the expression in the body of the delegate.
I had always thought that the delegate in VB.net had an optional Return statement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.