Hey all,

I am trying to reuse a bunch of Class members, properties, and functions
that are shared across multiple classes.  Each of these classes already
inherit form a web control so I can not create a base class supporting the
function since .Net does not support multiple inheritance.  Right now each
Inherited class has a complete copy of this code that makes it hard to make
changes to it.

So invision...
MyControl1--\                   /---BaseControl1
MyControl2--->Common Code Class<----BaseControl2
MyControl3--/                   \---BaseControl3

What I really need is multiple inheritance...

Public Class MyLabel
        Inherits System.Web.UI.WebControls.Label)
        Inherits MyCommonStuff

End Class

Since so many of these are shared properties and members using basic
interfaces would not really save that much code space.  What I was trying to
do is mix in generics and do something along these lines...

Public Class MyBaseControl(Of t)
        Inherits t

        Class members...
        Functions...
        Properties...
End Class

Public Class MyLabel
    Inherits MyBaseControl(Of System.Web.UI.WebControls.Label)

End Class

Public Class MyTextbox
    Inherits MyBaseControl(Of System.Web.UI.WebControls.Textbox)

End Class

So what I need is to somehow make my intermediate class inherit the base
control of my choice at runtime based on the type passed through the
generic.  Is anything like this possible?  I have not had any luck so far.

Thanks for any help,

Jon

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to