4
Reply

What is delegation ?? Can you give clear examples, and how can we define and use user-defined delegations?? What is teh combine and remove methods??

Wael Salman

Wael Salman

15y
6.3k
0
Reply

    += means you are defining a delegate for your function.

    suppose your function is hello()

    you want to call the function when user clicks on submit.

    In simple words you are telling the button call the function when you are clicked. :)

    Thank you

     

    and what is submitButton.click += ....  what is += means exactly in this situation?? how can you write it in simple way??

    Delegations

    Delegate is very simple it is pointer to your function.In simple words you can say you are invoking or calling your function.

    Suppose you have your userdefined function you want to call it at some point at a particular point of time you can use your delegate there.

    suppose if you want to define a delegate for a submit button you can define as

    btnSubmit.Click += newEventHandler(btnSubmit_Click);

    you can write the definition of btnSubmit_Click later

    Delegation is the simple yet powerful concept of handing a task over to another part of the program. In object-oriented programming it is used to describe the situation wherein one object defers a task to another object, known as the delegate. This mechanism is sometimes referred to as aggregation, consultation or forwarding