DarwinIcesurfer
DarwinIcesurfer

Reputation: 1123

Add an interface to a class that extends another class

I have a need to use the INotifyPropertyChanged interface on a class. This is needed to update values in a form when the underlying property changes.

This class already derives from another class which doesn't implement the INotifyPropertyChanged interface.

this doesn't work:

public class MyClass : BaseClass : INotifyPropertyChanged { }

I'd appreciate ideas on program structure changes or syntax changes that will let me accomplish the objective of updating the form when a property in the base class is changed.

Upvotes: 0

Views: 106

Answers (4)

Nick Harrison
Nick Harrison

Reputation: 937

public class MyClass : BaseClass, INotifyPropertyChanged {}

You will also need to provide an implementation for INotifyPropertyChanged.

Upvotes: 1

JohnD
JohnD

Reputation: 14757

Don't you just want to do this:

public class MyClass : BaseClass , INotifyPropertyChanged { }

(note the comma instead of the colon) Hope that helps,

John

Upvotes: 2

Brandon Moretz
Brandon Moretz

Reputation: 7621

public class MyClass : BaseClass : INotifyPropertyChanged {}

Should be:

public class MyClass : BaseClass, INotifyPropertyChanged {}

Upvotes: 1

Kirk Woll
Kirk Woll

Reputation: 77546

public class MyClass : BaseClass, INotifyPropertyChanged { }

(Add a comma after the base class)

Upvotes: 6

Related Questions