Delegate Syntax : Delegate « Language Basics « VB.Net






Delegate Syntax

  

Option Strict On
Imports System.Collections.Generic
Module Program
    Sub Main()

        Dim list As New List(Of Integer)()
        list.AddRange(New Integer() {20, 1, 4, 8, 9, 44})
        Dim callback As New Predicate(Of Integer)(AddressOf IsEvenNumber)
        Dim evenNumbers As List(Of Integer) = list.FindAll(callback)
        For Each evenNumber As Integer In evenNumbers
            Console.WriteLine(evenNumber)
        Next
    End Sub

    Function IsEvenNumber(ByVal i As Integer) As Boolean
        Return (i Mod 2) = 0
    End Function
End Module

   
    
  








Related examples in the same category

1.Delegate with and without parametersDelegate with and without parameters
2.Two ways to init a DelegateTwo ways to init a Delegate
3.Multicast DelegateMulticast Delegate
4.Use Delegate to implement custome sortUse Delegate to implement custome sort
5.Register Delegates and call themRegister Delegates and call them
6.Simple Delegate DemoSimple Delegate Demo
7.Sort DelegateSort Delegate
8.Function Delegation DemoFunction Delegation Demo
9.Function Delegate: output stringFunction Delegate: output string
10.Delegate Demo for a Simple ClassDelegate Demo for a Simple Class