Thirumal Reddy
What are Delegates? In which scenarios delegates come into picture. Can anybody explain with understandable examples?
By Thirumal Reddy in ASP.NET on May 19 2010
  • Satyapriya Nayak
    May, 2010 26

    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 Sub

     

    End Class

     

    • 0
  • laxmikant Mishra
    May, 2010 25

    Delegates are like a  object but it contains only reference of function member, neither it contain the copy  and reference of member variable of Class.
    And Return type and signature of delegates must be same as referencing methods
    Events are build up on delegate.

    • 0
  • kiran adhLAKHA
    May, 2010 20

    Delegates takes the responsiblity of another functrion

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS