How to write a VB.Net Lambda expression

82,046

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)
Share:
82,046

Related videos on Youtube

Venugopal M
Author by

Venugopal M

Developer since 2000, basically Microsoft platform. Worked on C++, FoxPro, MS Access, VB 5.0, VB 6.0, Visual Studio 2003-2015, Sql Server 2015, Oracle, FireBird DB, C#, Windows Desktop, ASP.Net, MVC, .Net Core, Entity Framework, NHibernate, Unity Framework, Web Services, Web API, Service Stack, SOAP, WCF, WPF, Windows Phone Apps, JQuery, HTML, CSS, Angular JS, EJS, Bootstrap and more...

Updated on July 05, 2022

Comments

  • Venugopal M
    Venugopal M almost 2 years

    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!

  • Paolo Moretti
    Paolo Moretti almost 11 years
    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.
  • Jeff Mercado
    Jeff Mercado almost 11 years
    I had always thought that the delegate in VB.net had an optional Return statement.