How to write a VB.Net Lambda expression

后端 未结 1 1484
难免孤独
难免孤独 2021-02-06 20:02

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);
<         


        
1条回答
  •  太阳男子
    2021-02-06 21:01

    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)
    

    0 讨论(0)
提交回复
热议问题