Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7968015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:00:39+00:00 2026-06-04T07:00:39+00:00

Delegate : I understand. But when I move to event, many things I don’t

  • 0

Delegate : I understand. But when I move to event, many things I don’t understand so much. I read book, MSDN and some simple examples on Network, they both have same structures. For example, here is the link : Event Example

I take the first example, that the author said it’s the most easiest example about C# Event.

Here is his code :

public class Metronome
{
    public event TickHandler Tick;
    public EventArgs e = null;
    public delegate void TickHandler(Metronome m, EventArgs e);
    public void Start()
    {
        while (true)
        {
            System.Threading.Thread.Sleep(3000);
            if (Tick != null)
            {
                Tick(this, e);
            }
        }
    }
}

public class Listener
{
    public void Subscribe(Metronome m)
    {
        m.Tick += new Metronome.TickHandler(HeardIt);
    }
    private void HeardIt(Metronome m, EventArgs e)
    {
        System.Console.WriteLine("HEARD IT");
    }
}

class Test
{
    static void Main()
    {
        Metronome m = new Metronome();
        Listener l = new Listener();
        l.Subscribe(m);
        m.Start();
    }
}

You can notice line: public event TickHandler Tick. When I change to public TickHandler Tick, program still run the same. But new line I understand because it’s just a pure delegate.

So, my question is : what is the real purpose of event keyword in line : public event TickHandler Tick. This is very important, because all examples always use like this, but I cannot explain why.

Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:00:40+00:00Added an answer on June 4, 2026 at 7:00 am

    Delegates and events are related concepts, but they are not the same thing. The term “delegate” tends to have two meanings (often glossed over):

    • A delegate type which is similar to a single method interface. (There are significant differences, but that’s a reasonable starting point.)
    • An instance of that type, often created via a method group, such that when the delegate is “invoked”, the method is called.

    An event is neither of those. It’s a kind of member in a type – a pair of add/remove methods, taking a delegate to subscribe to or unsubscribe from the event. The add and remove methods are used when you use foo.SomeEvent += handler; or foo.SomeEvent -= handler;.

    This is very similar to how a property is really a pair of get/set methods (or possibly just one of the two).

    When you declare a field-like event like this:

    public event TickHandler Tick;
    

    the compiler adds members to your class which are somewhat like this:

    private TickHandler tick;
    
    public event TickHandler
    {
        add { tick += value; }
        remove { tick -= value; }
    }
    

    It’s a bit more complicated than that, but that’s the basic idea – it’s a simple implementation of the event, just like an automatically implemented property. From inside the class, you can access the backing field, whereas outside the class you’ll always end up just using the event.

    Personally I think it’s a pity that the declaration of a field-like event looks so much like a field of a delegate type – it leads to some of the misleading (IMO) statements found in some of the answers, as if the event keyword “modifies” a field declaration – when actually it means you’re declaring something entirely different. I think it would have been clearer if field-like events looked more like automatically-implemented properties, e.g.

    // Not real C#, but I wish it were...
    public event TickHandler Tick { add; remove; }
    

    I have a whole article going into rather more detail, which you may find useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I read MSDN and Stack Overflow. I understand what the Action Delegate does
I've read the jQuery documentation on event handling, but I still can't really understand
I'm having some trouble understanding the delegate/data source methodology. I understand that they exist
I just read Factory Method. I understand that it provides a way to delegate
I have a working code from a tutorial but don't understand it completely. Situation:
I'm trying to understand how delegate pattern works. Below is some code that I
I understand what basic synthesizing does in objective C but I don't understand what
I am new to Iphone Dev, seems doesn't really understand delegate things. Could we
I don't really understand what delegate and promise are. According to the docs -
I understand why GUI controls have thread affinity. But why don't the controls use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.