You must Sign In to post a response.
  • Category: ASP.NET

    Where and all we use Delegate in Real time project

    Hai All,

    May I know where and all we can use delegate in our project

    Please Explain with any real time scenario

    Thanks and Regards,
  • #761390
    We are using the "delicate" most of the time for creating the events

    If you are creating the user control and want to handle some events. In that case we can use the delicate

    By Nathan
    Direction is important than speed

  • #761393
    Hi Chellapan.

    Delegates holds address of one or more methods.
    These are used to hide information like class
    names and method names.
    Delegates are used to create user defined events
    on fly as we needed in our code.
    Delegates are of two types
    1.Single cast delegate
    2.Multi caste delegate
    Sample code:
    Class Sample
    public void dosomething();
    MessageBox.Show("Am from dosomething
    public delegate void delegate_name();
    code for btn_Click
    Sample obj=new Sample();// creating object for
    delegate with address of method.
    delegate_name obj2=new delegate_name
    obj2(); // call delegate object.


    Thota Sridhar.

    Sridhar Thota.
    Editor: DNS Forum.

  • #761423
    Hai Chellappan,
    When you don't have a predefined event, you can simply create a delegate and attach to it to perform certain tasks.

    public delegate void AddButtonClick();

    Now you can attach this delete to an event like:

    ImageControl.addButtonClick += new Image.AddButtonClick(AddProfileImage);

    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #761447
    Hi Chellapan.

    When we want the controls logic and forms logic
    to be executed at one shot, we create a custom
    event to fire both logics at a time.

    While working in real time you will get
    requirement like when predefined events are not
    enough to handle the logic then we create custom
    events on fly.

    Read how to create delegates and how to create
    user defined events.


    Thota Sridhar.
    If you learn from defeat..
    You haven't really lost..

    Sridhar Thota.
    Editor: DNS Forum.

  • #761461

    As per my understanding "In a project (like WorkFlow based project) If the flow gets struck for "X" Approvals but "X" is on long leave, in that case he is delegate his permission to "Y" and "Y" continue the flow without help of "X", In this scenario we go for delegates concept".

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • Sign In to post your comments