What are Delegates? In which scenarios delegates come into picture. Can anybody explain with understandable examples?
Thirumal Reddy
Select an image from your device to upload
It is a procedure pointer which stores the memory address of another procedure.
Example:-
Public Class Form1
Inherits System.Windows.Forms.Form
Delegate Sub abhisek(ByVal x As Integer, ByVal y As Integer)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As abhisek
a = AddressOf rajiv
a.Invoke(10, 20)
End Sub
Public Sub rajiv(ByVal x As Integer, ByVal y As Integer)
Dim z As Integer
z = x + y
MsgBox(z)
End Class