Can a C# Interface require or dictate a specific class?

Viewed 2705

Can I declare an Interface (i.e. IMySpecialControl) that requires classes implementing it to also inherit from some base class (i.e. System.Windows.Controls.UserControl)?

My thinking is that, no, this is not possible. But it would be really nice to write client code in such a way that it only takes a 'IMySpecialControl' which defines several members it cares about and it can count on that object also being a UserControl that it can then add to the GUI or manipulate.

I know that I can always check if the object instance defined as a 'IMySpecialControl' is also a UserControl, but I was hoping there might be some slick trick in .Net I'm not aware of. :-)

2 Answers
Related