In VB.NET 9.0 Lambda is one of the features we have here. Lambda expression is just another way to call Anonymous method/delegate.
Let’s look into a generic list of integers, and play with it,
Dim arrInt As New List(Of Integer)
For i As Integer = 1 To 10
arrInt.Add(i)
Next
When you need to get the even numbers out of this List, you can call delegate,
Dim even1 As New List(Of Integer)
even1 = arrInt.FindAll(New Predicate(Of Integer)(AddressOf EvenGetter))
Then for this approach you need a method,
Public Function EvenGetter(ByVal i2 As Integer) As Boolean
Return i2 Mod 2 = 0
End Function
Using VB.NET 9.0 you can also implement Lambda Expression,
even1 = arrInt.FindAll(Function(i2 As Integer) i2 Mod 2 = 0)
Ask expert for more.
Namoskar!!!
In VB.NET 9.0 Lambda is one of the features we have here. Lambda expression is just another way to call
Thanks. Was trying to figure out the syntax for lambda expression in vb.net as i'm a c# guy.
Nice,
How do I convert thefollowing c# code to VB.Net using Lambda Expression:
synchronizationContext.Post((e) => action((T)e), eventArgs);
THanks
Atallah
synchronizationContext.Post((Function(e as T) action(e)), eventArgs)
Very Good! Thanks you very much!
Now I understand on 'Lambda' clearly.