Alex Rivera | Logout

Short way to write an event?

Asked 2011-02-10T16:25:48.643
11

Typically we use this code:

    private EventHandler _updateErrorIcons;
    public event EventHandler UpdateErrorIcons
    {
        add { _updateErrorIcons += value; }
        remove { _updateErrorIcons -= value; }
    }

Is there a similar shortcut like with automatic properties? Something like:

   public event EventHandler UpdateErrorIcons { add; remove; }
Edit
Report

1 Answer

5
public event EventHandler UpdateErrorIcons; 

is just fine

you can use

yourObbject.UpdateErrorIcons += YourFunction;
answered 2011-02-10T16:27:42.117

Your Answer