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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:00:59+00:00 2026-05-15T15:00:59+00:00

Possible Duplicate: C#: Difference between ‘ += anEvent’ and ‘ += new EventHandler(anEvent)’ Hi

  • 0

Possible Duplicate:
C#: Difference between ‘ += anEvent’ and ‘ += new EventHandler(anEvent)’

Hi all,

I have two eventhandlers.

In my constructor I attach a function to the eventhandler but do it in different ways for the two eventhandlers. One with new Eventhandler, the other by just pointing to the function. They seem to do the same?

What is the prefered way and why?

UPDATE: already answered here

public partial class MyForm : Form
{
    public event EventHandler Button1Clicked;
    public event EventHandler Button2Clicked;

    public MyForm()
    {
        InitializeComponent();

        simpleButton1.Click += new EventHandler(simpleButton1_Click);
        simpleButton2.Click += Button2Click;
    }

    void simpleButton1_Click(object sender, EventArgs e)
    {
        if (Button1Clicked != null)
        {
            Button1Clicked.Invoke(sender, e);
        }
    }

    void Button2Click(object sender, EventArgs e)
    {
        if (Button2Clicked != null)
        {
            Button2Clicked.Invoke(sender, e);
        }
    }
}
  • 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-05-15T15:01:00+00:00Added an answer on May 15, 2026 at 3:01 pm

    C# 2 introduced method group conversions which is what your second form is using. It does exactly the same thing internally – in both cases, it produces a new instance of EventHandler.

    Personally I prefer the second form: it doesn’t have as much cruft. It just says what you’re interested in.

    (I hadn’t spotted the exact duplicate. Leaving this answer here despite closing the question, as it’s doing no harm.)

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

Sidebar

Related Questions

Possible Duplicate: C#: Difference between ‘ += anEvent’ and ‘ += new EventHandler(anEvent)’ Let
Possible Duplicate: Ruby: difference between || and ‘or’ Using Ruby || and or are
Possible Duplicate: Difference between Color.red and Color.RED I have seen that the Java class
Possible Duplicate: C# newbie: what’s the difference between “bool” and “bool?” ? Hi, While
Possible Duplicate: Difference between (function(){})(); and function(){}(); I have seen it a lot by
Possible Duplicate: The difference between the two functions? (“function x” vs “var x =
Possible Duplicate: What the difference between “$@” and “$*” in bash? For years and
Possible Duplicate: What is the difference between String.Empty and “” Is equivalent to String.Empty
Possible Duplicate: What is the difference between char a[] = “string” and char *p
Possible Duplicate: ASP.NET “special” tags What is the difference between <%# ... %> ,

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.