Vb.net lambda syntax features:
The lambda expression has no name.
Lambda expressions cannot have modifiers, such as Overloads or Overrides.
Lambda expressions do not use the As clause to specify the function return type. On the contrary, the type is derived from the value calculated by the lambda expression body. For example, if the body of a lambda expression is Where cust. City = "London", the return type is Boolean.
The function must be an expression rather than a statement. The function body can contain calls to the function process, but cannot contain calls to the child process.
The Return statement does not exist. The value returned by the function is the value of the expression in the function body.
The End Function statement does not exist.
Either all parameters must have the specified data type or all types must be inferred.
Optional and Paramarray parameters are not allowed.
Generic parameters are not allowed.
Due to the above restrictions, and the use of lambda expressions, lambda expressions are generally short and not complex.
Example:
Private Sub Button3_Click (ByVal sender As System. Object, ByVal e As System. EventArgs) Handles Button3.Click
Dim ArrInt As New List (Of Integer)
For I As Integer = 1 To 20
ArrInt. Add (I)
Next
Dim EvenOne As New List (Of Integer)
EvenOne = ArrInt. FindAll (New Predicate (Of Integer) (AddressOf EvenGetter ))
For Each m In EvenOne
Console. WriteLine (m)
Next
Dim EvenTwo As New List (Of Integer)
EvenTwo = ArrInt. FindAll (Function (p As Integer) p Mod 2 = 0)
For Each m In EvenTwo
Console. WriteLine (m)
Next
End Sub
Public Function EvenGetter (ByVal p As Integer) As Boolean
Return p Mod 2 = 0
End Function
Author: "wl58796351 column"