15

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

During my searches I always 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.

1 Answer 1

31

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)
Sign up to request clarification or add additional context in comments.

Comments

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.