85

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!

Gary Barrett
  • 1,764
  • 5
  • 21
  • 33
Venugopal M
  • 2,280
  • 1
  • 20
  • 30

1 Answers1

114

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)
Jeff Mercado
  • 129,526
  • 32
  • 251
  • 272
  • 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. – Paolo Moretti Aug 19 '13 at 15:29
  • I had always thought that the delegate in VB.net had an optional `Return` statement. – Jeff Mercado Aug 19 '13 at 15:37