2

I have C# class definition

MyViewModelClass: INotifyPropertyChanged, MyAbstractBaseForVMClass

It won't compile. Gives and error at the start of MyAbstractBaseForVMClass literal:

Interface definition is expected.

Can I not realize an interface, and inherit from an abstract class at the same time?

Maxim V. Pavlov
  • 10,303
  • 17
  • 74
  • 174

1 Answers1

8

No you can. Just reverse them.

MyViewModelClass: MyAbstractBaseForVMClass, INotifyPropertyChanged

Interfaces always come after classes.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
  • Thanks. Do you know logical explanation to this limitation? – Maxim V. Pavlov Aug 25 '11 at 17:59
  • Here is another question. http://stackoverflow.com/questions/5675580/why-must-the-base-class-be-specified-before-interfaces-when-declaring-a-derived-c – Daniel A. White Aug 25 '11 at 18:00
  • My guess is, because there is no multiple inheritance besides interfaces, the first must be the base or abstract class and after that follows the interfaces, which can be of course more than one. – dowhilefor Aug 25 '11 at 18:02
  • I didn't know that there was such a limitation, therefor was unable to find that question by name. Thanks. – Maxim V. Pavlov Aug 25 '11 at 18:02