I want to have a abstract view for any type of UI (web or window). In order to do that I must use Interface (IView ) in which I can only apply just rules about view. In fact, I want to set a some basic comple function to provide to its inheritances.
So in this way, I must use abstract class. The problem is
1) Interface only have rules 2) The view (web form or window form) can’t inherit any more since that’s already inherited from window or web form
How can I do that? Many thanks
Will the functions you add change the definition of what the class is, or will you simply be creating functions to manipulate data that is already a part of the class?
If you need to redefine aspects of the base class of these two classes then yes, you will need to change your inheritance structure. But if the functions will simply manipulate data that is already part of the class now then I would suggest you use the interface and create utility functions.
Here is a clumsy example of what I mean:
Your two UI classes are perhaps related in this way. I would imagine that what you need to do in a cross-cutting fashion would be solved by a utility method like the one I have created. I did create the
PetUtils.Printmethod as an extension method as this will create the expressive illusion of an instance method. If you are not using C# 3 just remove ‘this‘ frompublic static void Print(this IPet pet).