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 7824735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:42:07+00:00 2026-06-02T08:42:07+00:00

Here’s an interesting question I never really thought about until I had a conversation

  • 0

Here’s an interesting question I never really thought about until I had a conversation with a co-worker last week.

When we add an event handler, we use syntax such as:

Button1.Click += ClickHandler

As far as I can tell, we use += synonymously with “add” and -= synonymously with “remove”.

So my question is, why did the language creators choose to use this sort of syntax? Why not Button1.Click.Add(ClickHandler)?

If it just means add, why wouldn’t the framework creators overload the += operator for List instead of .Add()?

I imagine it’s the same reason which explains the existence of AddHandler and RemoveHandler in VB.Net but I have no idea what that reason is.

Why is there special language syntax for adding and removing event handlers?

  • 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-02T08:42:09+00:00Added an answer on June 2, 2026 at 8:42 am

    Very subjective question, the guys that defined the syntax don’t post to SO so it mind reading is required to guess at their motivations 14 years ago. Having a stab at it anyway:

    An event is the exact equivalent of a property. Just like a property limits access to a field, an event limits access to a delegate object. A property has a getter and a setter. Only the = symbol is required to invoke them. One is enough, the compiler can figure out if the setter or the getter is intended from location of the property identifier relative to the = symbol (left is setter, right is getter).

    An event has three accessors: add, remove and raise. Raise is not implemented in C# (unlike other languages) so we just need syntax for add and remove. We can’t do with just one symbol like we can with properties, placement isn’t helpful. The most natural symbol for add is +, for remove is -. It also behaves somewhat as an assignment since it logically (and in practice) re-assigns the underlying delegate object. So natural choices are += and -=.

    No idea if the designers in fact followed the same logic. The VB.NET designers certainly didn’t, they picked language keywords to map to accessors (AddHandler, RemoveHandler, RaiseEvent). But C# is the kind of language where syntax brevity and an absolute minimum number of keywords were strong design goals. C++/CLI is pretty similar to C# but with support for the raise accessor and no syntax sugar at all to create a delegate object. Which gives it capabilities beyond C#, it isn’t limited to making this the delegate target, a feature called “unbound delegates”.

    One final note, that delegate object creation syntax sugar that C# has but C++/CLI doesn’t is pretty important. Because if you write it out, you’ll get code like this:

    SystemEvents.UserPreferenceChanged -= new UserPreferenceChangedEventHandler(repaintControls);
    

    Which bedevils the mind of any programmer starting with .NET programming. You have to create a new delegate object in order to unsubscribe an event??? Yes you do. The sugar is a lot more understandable:

    SystemEvents.UserPreferenceChanged -= repaintControls;
    

    The compiler generates the same code anyway. Also the probable reason that VB.NET went with keywords.

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

Sidebar

Related Questions

here is a debatable question which i want to achieve not sure how .
Here is a simple demonstration of what I'm talking about js in head tag:
Here a simple question : What do you think of code which use try
Here is my question. I am having this simple menu. <div id=menu> <ul> <li>
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's an interesting problem. On a recently installed Server 2008 64bit I opened IE
Here's the thing: I want to add some images programmatically. The images should have
Here is my problem...I have a page that loads a list of clients and
Here is some code I made :) @echo off set source=R:\Contracts\ set destination=R:\Contracts\Sites\ ROBOCOPY
Here is the situation, I am attempting to fire a set of Gallio tests

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.