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

  • Home
  • SEARCH
  • 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 280385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:06:51+00:00 2026-05-12T05:06:51+00:00

I understand the benefits of using the standard MS event handler delegate signature as

  • 0

I understand the benefits of using the standard MS event handler delegate signature as it allows you to easily expand on the information passed through the event with out breaking any old relationships that are based on the old delegate signature.

What I’m wondering is in practice how often do people follow this rule? Say I have a simple event like this

public event NameChangedHandler NameChanged;
public delegate void NameChangedHandler(Object sender, string oldName, string newName);

It’s a simple event, and I’m nearly positive that the only arguments I’m ever going to need to know from the NameChanged event is the object whose name changed, the old name, and the new name. So is it worth it to create a separate NameChangedEventArgs class, or for simple events like this is it acceptable to just return the the arguments directly through the delegate arguments?

  • 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-12T05:06:51+00:00Added an answer on May 12, 2026 at 5:06 am

    You can do anything the wrong way if you’re the only one who has to deal with it. But it’s not a bad idea to learn standards and stick to them so that you keep good habits when you’re working on code with others.

    So I’ll make you a deal. If you promise to do it the right way, I’ll give you a code snippet that’ll make it much less of a pain. Just put this in a .snippet file, and put that file in:

    My Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets\
    (or Visual Studio 2005 if applicable)

    And here’s the snippet; use it in VS by typing ev2Generic and hitting Tab:

    <?xml version="1.0" encoding="utf-8" ?>
    <CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
      <CodeSnippet Format="1.0.0">
        <Header>
          <Title>Generic event with two types/arguments.</Title>
          <Shortcut>ev2Generic</Shortcut>
          <Description>Code snippet for event handler and On method</Description>
          <Author>Kyralessa</Author>
          <SnippetTypes>
            <SnippetType>Expansion</SnippetType>
          </SnippetTypes>
        </Header>
        <Snippet>
          <Declarations>
            <Literal>
              <ID>type1</ID>
              <ToolTip>Type of the first property in the EventArgs subclass.</ToolTip>
              <Default>propertyType1</Default>
            </Literal>
            <Literal>
              <ID>arg1Name</ID>
              <ToolTip>Name of the first argument in the EventArgs subclass constructor.</ToolTip>
              <Default>property1Name</Default>
            </Literal>
            <Literal>
              <ID>property1Name</ID>
              <ToolTip>Name of the first property in the EventArgs subclass.</ToolTip>
              <Default>Property1Name</Default>
            </Literal>
            <Literal>
              <ID>type2</ID>
              <ToolTip>Type of the second property in the EventArgs subclass.</ToolTip>
              <Default>propertyType2</Default>
            </Literal>
            <Literal>
              <ID>arg2Name</ID>
              <ToolTip>Name of the second argument in the EventArgs subclass constructor.</ToolTip>
              <Default>property2Name</Default>
            </Literal>
            <Literal>
              <ID>property2Name</ID>
              <ToolTip>Name of the second property in the EventArgs subclass.</ToolTip>
              <Default>Property2Name</Default>
            </Literal>
            <Literal>
              <ID>eventName</ID>
              <ToolTip>Name of the event</ToolTip>
              <Default>NameOfEvent</Default>
            </Literal>
          </Declarations>
          <Code Language="CSharp">
            <![CDATA[public class $eventName$EventArgs : System.EventArgs
          {
            public $eventName$EventArgs($type1$ $arg1Name$, $type2$ $arg2Name$)
            {
              this.$property1Name$ = $arg1Name$;
              this.$property2Name$ = $arg2Name$;
            }
    
            public $type1$ $property1Name$ { get; private set; }
            public $type2$ $property2Name$ { get; private set; }
          }
    
          public event EventHandler<$eventName$EventArgs> $eventName$;
                protected virtual void On$eventName$($eventName$EventArgs e)
                {
                    var handler = $eventName$;
                    if (handler != null)
                        handler(this, e);
                }]]>
          </Code>
        </Snippet>
      </CodeSnippet>
    </CodeSnippets>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand the benefits of events using delegate types with signature delegate void delegate_name(object
I'm just trying to understand the main benefits of using the Visitor pattern. Here's
I'm kinda new to concurrent programming, and trying to understand the benefits of using
I'm trying to understand the benefits of using a URL routing (URL dispatch) over
What is the benefit of using POCO? I don't understand the meaning of Persistence
I understand the benefits of cleaning all data and quoting data, etc, but I'm
I understand the many benefits of providing an interface to access the members of
I understand the benefits of three tier architecture ( for example, changing code in
Possible Duplicate: What are the benefits of using Boost.Phoenix? So I started reading the
Possible Duplicate: What are the benefits to using anonymous functions instead of named functions

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.