|
Module MulticastDelegates
Public Delegate Sub GreetingDelegate(ByVal MsgString As String)
Public Sub GoodMorning(ByVal YourName As String)
Console.WriteLine("Good Morning " + YourName + " !")
End Sub
Public Sub GoodNight(ByVal YourName As String)
Console.WriteLine("Good Night " + YourName + " !")
End Sub
Public Sub GoodEvening(ByVal YourName As String)
Console.WriteLine("Good Evening " + YourName + " !")
End Sub
Sub Main()
Dim MorningGreets As GreetingDelegate = AddressOf GoodMorning
Dim EveningGreets As GreetingDelegate
'MorningGreets()
EveningGreets = New GreetingDelegate(AddressOf GoodEvening)
Console.WriteLine()
Console.WriteLine("Adding 'MoringGreets' And 'EveningGreets' References To A Delegate...")
Dim AllGreets As GreetingDelegate = [Delegate].Combine(MorningGreets, EveningGreets)
Console.WriteLine("Invoking Delegate...")
AllGreets("Mallinath")
Console.WriteLine()
Console.WriteLine("Adding Another References To Existing Delegate...")
AllGreets = [Delegate].Combine(AllGreets, New GreetingDelegate(AddressOf GoodNight))
Console.WriteLine("Invoking Delegate...")
AllGreets("Mallinath")
Console.WriteLine()
Console.WriteLine("Removing 'GoodEvening' Regerence...")
Console.WriteLine("Invoking Delegate After Removing A 'GoodEvening'...")
AllGreets = [Delegate].Remove(AllGreets, EveningGreets)
AllGreets("Mallinath")
Console.WriteLine()
End Sub
End Module
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here