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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:38:26+00:00 2026-05-16T08:38:26+00:00

i need some help understanding how i can create a new custom event. i

  • 0

i need some help understanding how i can create a new custom event. i read from here …

public delegate void ChangingHandler (object sender, CarArgs ca); 
public event ChangingHandler Change; 
...
private void car_Change(object sender, CarArgs ca) {
    MessageBox.Show(ca.Message());
} 
...
car.Change+=new Car.ChangingHandler(car_Change); // add event handler
...
Change(this,ca); // call event

1st, i dont really get the delegate part. in a normal variable declartion,

protected string str1;

but here i have the extra (ChangingHandler). how do i make sense of this? i know its something like a ChangingHandler will be used for handling the event but it throws me off abit.

public event ChangingHandler Change

then

car.Change+=new Car.ChangingHandler(car_Change)

i dont really get the syntax new Car.ChangingHandler(car_Change).

  • 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-16T08:38:27+00:00Added an answer on May 16, 2026 at 8:38 am

    An event in C# is sort of like a collection of method pointers. It says “hey everyone, if you care about me, give me a pointer to a method I can invoke, I’ll hold onto it, and when I feel like announcing to the world what is up, I’ll invoke all the methods you gave me.”

    That way someone can give the event a pointer to their method, which is referred to as a “event handler”. The event will call this method whenever the event’s owner feels it is appropriate.

    The delegate, in this sense, is nothing more than saying what kind of method the event will accept. You can’t have one person giving the event a method that takes no arguments and one that takes 5, it’d have no idea how to call them. So the delegate is the contract between the event and the event handler, telling them both what to expect for the method signature.

    In your case, it is probably better to just use EventHandler<T>, which is a built in delegate of the form void EventHandler<T>(object sender, T eventArgs) for your event delegate, like this:

    public event EventHandler<CarArgs> Change;
    

    C# doesn’t actually have function pointers in the raw sense. Delegates handle this instead. They are like strongly typed, object oriented function pointers. When you call

    car.Change+=new Car.ChangingHandler(car_Change);
    

    You are giving the event a new delegate (function pointer) that points to your car_Change event handler, telling the event to call your car_Change method when it is ready. The delegate (new ChangeHandler(...) simply wraps the pointer to the car_Change method.

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

Sidebar

Related Questions

I need help understanding some C++ operator overload statements. The class is declared like
I need some help from the shell-script gurus out there. I have a .txt
I need some help ... I'm a bit (read total) n00b when it comes
I am new to all the anonymous features and need some help. I have
I need some help regarding algorithm for randomness. So Problem is. There are 50
I need some help calculating Pi. I am trying to write a python program
I need some help with jQuery script again :-) Just trying to play with
Hi I need some help with the following scenario in php. I have a
I am getting a little confused and need some help please. Take these two
I'm working with jQuery for the first time and need some help. I have

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.