Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

enforce event calling on inherited classes

Status
Not open for further replies.

SavantMan

Programmer
Apr 17, 2002
165
US
I have an abstract class that about a dozen sub-classes inherit from. I want to enforce that each sub-class shadows an event in the abstract class, but can't quite figure out how to do this.

Basically, all of the inherited classes deal with data in some way or another. I need to make sure that when the data is changed on any of those classes, they raise an event called "DataChanged", and have that enforced in some way from the abstract class.

I've tried a number of approaches, including "MustOverride Event", which apparently isn't allowed. Also, I've created an interface with just the DataChanged event, but there doesn't appear to be any sort of "Must Implement" available --- to make matters worse, when trying to raise an event from the inherited class on the abstract class, that doesn't appear to be allowed either.

Obviously I can create an interface and just "remember" that every one of the sub-classes must implement this interface, but that's error prone and relies on me remembering additional steps, which obviously isn't a good idea.

Any suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top