© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
21 replies
stigzler

Events when implementing Interfaces

Hi - Hobby coder here. Trying to expand my coding. My query is around using Events in Interfaces. Let's say I have an interface that includes:

event EventHandler<IGame> GameClicked;
event EventHandler<IGame> GameClicked;

When I do "Implement reminaing memebers explicity" (I often add to my inerface as I go) I get the following:

event EventHandler<IGame> IGamesView.GameClicked
{
    add
    {
        throw new NotImplementedException();
    }

    remove
    {
        throw new NotImplementedException();
    }
}
event EventHandler<IGame> IGamesView.GameClicked
{
    add
    {
        throw new NotImplementedException();
    }

    remove
    {
        throw new NotImplementedException();
    }
}

I can't figure out how to implent this in code. I am wanting to fire the event when a user clicks a button. The only way I can find to get it working is by changing the above to:

public event EventHandler<IGame> GameClicked;
public event EventHandler<IGame> GameClicked;


And then, on button click:

GameClicked.Invoke(sender, (IGame)e.Item);
GameClicked.Invoke(sender, (IGame)e.Item);


However, the problem with this approach is that I don't want GameClicked to be
Public
Public
. However, if I change it to
Internal
Internal
it won't compile due to the INterface needing implementing again..

I know I'm getting things mixed up in terms of the core ideas and have done lots of reading around Delegates etc, but just getting more confused. What's the simplest way to achieve the above without the event being public?
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

Dynamically Implementing Interfaces at Runtime
C#CC# / help
15mo ago
Interfaces
C#CC# / help
3y ago
✅ When to use interfaces and why
C#CC# / help
11mo ago
C# interfaces
C#CC# / help
2y ago