Explain the delegates in C#.

Delegates in C# are objects which points towards a function which matches its signature. Delegates are reference type used to encapsulate a method with a specific signature. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure.
Here are some features of delegates:

  • A delegate represents a class.
  • A delegate is type-safe.
  • We can use delegates both for static and instance methods
  • We can combine multiple delegates into a single delegate.
  • Delegates are often used in event-based programming, such as publish/subscribe.
  • We can use delegates in asynchronous-style programming.
  • We can define delegates inside or outside of classes.
Syntax of using delegates

//Declaring delegate
delegate void SampleDelegate(string message);

// declare method with same signature:
static void SampleDelegateMethod(string message) { Console.WriteLine(message); }

// create delegate object
SampleDelegate d1 = SampleDelegateMethod;

// Invoke method with delegate
d1("my program");

19 comments:

  1. great post, it answerd most of my questions, thanks!

    ReplyDelete
  2. Hey... Nice one....
    Wants some entertainment go to Funkyoinky

    ReplyDelete
  3. cddddddddddddd








    ssssssss















































    sssss

    ReplyDelete
  4. Greetings! Very helpful advice within this article!
    It is the little changes which will make the largest changes.
    Many thanks for sharing!

    Here is my blog bock of ra

    ReplyDelete
  5. Hey there just wanted to give you a brief heads up and let you know a few of the pictures aren't loading properly. I'm
    not sure why but I think its a linking issue. I've tried it in two different web browsers and both show the same results.

    Also visit my weblog book auf ra kostenlos spielen

    ReplyDelete
  6. I am genuinely grateful to the owner of this web site who has shared
    this wonderful paragraph at at this place.


    my web page; book of ra kostenlos ohne anmeldung

    ReplyDelete
  7. Hello! Do you know if they make any plugins to help with SEO?
    I'm trying to get my blog to rank for some targeted keywords but I'm not seeing very good results.

    If you know of any please share. Cheers!

    Also visit my web page; book of ra download

    ReplyDelete
  8. Hi! I know this is kinda off topic but I was wondering if you knew where I could locate a captcha plugin
    for my comment form? I'm using the same blog platform as yours and I'm having
    difficulty finding one? Thanks a lot!

    Here is my site novoline spiele kostenlos spielen

    ReplyDelete
  9. I loved as much as you'll receive carried out right here. The sketch is attractive, your authored material stylish. nonetheless, you command get got an shakiness over that you wish be delivering the following. unwell unquestionably come more formerly again since exactly the same nearly very often inside case you shield this hike.

    Also visit my blog ... https://new.byelizabeth.com/

    ReplyDelete
  10. Yesterday, while I was at work, my sister stole my iPad and tested to see if it can survive
    a 30 foot drop, just so she can be a youtube sensation.
    My iPad is now destroyed and she has 83 views.
    I know this is totally off topic but I had to share it with someone!



    my web site: sizzling hot deluxe tricks

    ReplyDelete
  11. I loved as much as you will receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get bought an edginess over that you wish be delivering the following.

    IELTS Coaching in chennai

    German Classes in Chennai

    GRE Coaching Classes in Chennai

    TOEFL Coaching in Chennai

    spoken english classes in chennai | Communication training

    ReplyDelete
  12. Nice blog, it’s so knowledgeable, informative, and good looking site. I appreciate your hard work. Good job. Thank you for this wonderful sharing with us. Keep Sharing.
    Nice blog, it’s so knowledgeable, informative, and good looking site. I appreciate your hard work. Good job. Thank you for this wonderful sharing with us. Keep Sharing.
    DevOps Training in Chennai

    DevOps Online Training in Chennai

    DevOps Training in Bangalore

    DevOps Training in Hyderabad

    DevOps Training in Coimbatore

    DevOps Training

    DevOps Online Training

    ReplyDelete
  13. its very useful to us.This is incredible,I feel really happy to have seen your webpage I gained many unknown information, the way you have clearly explained is really fantastic.keep posting such useful information.

    python training in chennai

    python course in chennai

    python online training in chennai

    python training in bangalore

    python training in hyderabad

    python online training

    python training

    python flask training

    python flask online training

    python training in coimbatore

    ReplyDelete

Type more interview question answer here