© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
20 replies
Yonatan

How do I call a null event?

public delegate void MyDel();

        public event MyDel MyEvent;

        public void LeftClickPressed()
        {
            if (MyEvent != null)
                MyEvent();
        }
public delegate void MyDel();

        public event MyDel MyEvent;

        public void LeftClickPressed()
        {
            if (MyEvent != null)
                MyEvent();
        }

In here, the event is always null.
I Subscribed to it from a different class so everytime I trigger this event, a function will also run from that second class.

However this event never triggers because it is always null.
What Am I missing here?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How do i handle an event
C#CC# / help
2y ago
❔ How do i call a method from another script
C#CC# / help
3y ago
How do I call the constructor of a parent class?
C#CC# / help
3y ago
❔ Using Event Handler null exception
C#CC# / help
4y ago