开发者

Examples of VB.NET lambda expression

开发者 https://www.devze.com 2023-02-08 01:53 出处:网络
Where can I find complex LINQ examples made using VB.NET Lambda Expression syntax? During my searches I a开发者_如何学Golways found 101 LINQ Samples but they use the other notation and for me is not

Where can I find complex LINQ examples made using VB.NET Lambda Expression syntax?

During my searches I a开发者_如何学Golways found 101 LINQ Samples but they use the other notation and for me is not always clear how to transform that code into a lambda expression.


You could just look at MSDN. They have at least one example for each of the IEnumerable-extensions in C# and also in VB.Net.

Some random examples:

' Select
Dim squares As IEnumerable(Of Integer) = _
        Enumerable.Range(1, 10).Select(Function(x) x * x)

' Aggregate
Dim reversed As String = _
        words.Aggregate(Function(ByVal current, ByVal word) word & " " & current)

' Max
Dim max As Integer = pets.Max(Function(pet) _
                                      pet.Age + pet.Name.Length)

 ' SkipWhile
Dim query As IEnumerable(Of Integer) = _
        amounts.SkipWhile(Function(amount, index) _
                              amount > index * 1000)
0

精彩评论

暂无评论...
验证码 换一张
取 消