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

  • SEARCH
  • Home
  • 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 937113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:25:25+00:00 2026-05-15T21:25:25+00:00

My base interface IFoo declares event EventHandler Changed when I do ‘implement interface’ I

  • 0

My base interface IFoo declares

event EventHandler Changed

when I do ‘implement interface’ I get some lame boilerplate code but how do I provide a decent default implementation?

add { throw new NotImplementedException(); }
remove { throw new NotImplementedException(); }
  • 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-15T21:25:26+00:00Added an answer on May 15, 2026 at 9:25 pm

    How does the interface declare the event with the interface name prefixed on the event name? I’m not sure that’s legal C#.

    If you can get away without the “IFoo.” prefix, just declare the event in your class and let the compiler create the default add/remove handers for you. All you should have to worry about is when to trigger the event:

    interface IFoo
    {
        event EventHandler OnChanged;
    }
    
    class MyClass : IFoo
    {
        public event EventHandler OnChanged;
    
        private FireOnChanged()
        {
            EventHandler handler = this.OnChanged;
            if (handler != null)
            {
                handler(this, EventArgs.Empty); // with appropriate args, of course...
            }
        }
    }
    

    … Or did I misunderstand about where you’re inheriting the event from? is your class derived from an abstract base class which in turn implements an interface (which declares the event)? That could be what you mean, but it wasn’t clear in the question.

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

Sidebar

Related Questions

Lets say I have some interfaces: public interface IFoo { IBar DoesStuff(); } public
I get this warning when compiling my code in VS2008 warning C4275: non dll-interface
I am getting this error: type Bar does not implement interface IFoo From this
Suppose I have a pure virtual method in the base interface that returns to
Possible Duplicate: Ternary Expression with Interfaces as a Base Class Classes: interface ISms {
Given a base class with the following interface: public class Base { public virtual
If I defined an interface in a base class and I'm calling that interface
I have an interface with several events I have base class implementing the interface
I am trying to provide an interface to an abstract generic base class. I
I am working on a program base on C++ and also using SiliconSoftware interface.

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.