C#C
C#3y ago
Asher

❔ Using Event Handler null exception

Definition (in EventHandlerClass)
public EventHandler<ActionMessage> OnAction;

Usage:
EventHandlerClass.OnAction += ActionUsage;

this gives me a null exception on the Usage line, is there something I'm doing wrong here? (this is before invoking, or doing anything else, however, I do think it has something to do with OnAction not being initialized, but I couldn't find any examples where it is initialized.

The handler signature and event args match.
Is this correct usage? or do I have something else wrong with my code?
Was this page helpful?