vb.net - Return Inherited Generics as Base Generic -


After

itemprop = "text">

I BaseAbstractClass (VB generics) that inherited as (Webcontrol ) Webcontrol .

BaseAbstractClass ConcreteWrapper1 , inherited by ConcreteWrapper2 , and finally, shake things a bit, ConcreteWrapper4 . Each of them must use a different class inherited from BaseAbstractClass to WebControl .

What I want to do is a factory that gives concrete access a as BaseAbstractClass (WebControl) .

[edit: code added]

BaseAbstractClass

p>

  public MustInherit class inherits the Web Protector inherited as WebArthClass (TK Webcontrol) T protected override sub submission (byVal author System.Web.UI.HtmlTextWriter) _item.RenderControl (author) End Sub End Class  

Other ConcreteWrappers will look like this except for separate CustomControl

  Public Class ConcreteWrapper1 inherited BaseAbstractClass (CustomControlInheritedFromWebControl1) MyDesum = Control and Sub End Class Public Class Custom Controll Inheritance Web Controller 1 WebControl // does not use the correct comment markers but the color works better / works here The ... Implam is not important End Class  

My Factory

  Public Class WebControlFactory Public Shared Function GetWebControl () BaseAbstractClass (Webcontro L) Return as New ConcreteWrapper1 (New CustomControlInheritedFromWebControl1 ()) End Function Angle Class  

[/ edit]

What am I going to do and why work Can I get an explanation (and perhaps, no solution)?

Thank you!

concrete use 1 does not inherit BaseAbstractClass (of Webcontrol) , instead of (T) BaseAbstractClass

there is no interchange with BAC (TK) of BAC (Webcontrol).

If you want to use heirs, then you need the abstraction of two levels. BAC has inherited webcontraction BAC (T) inherited BAC wrapper 1 BAC (int ki) bac (string) wrapper raper 3 racper 4 legacy of BAC (TS BAC) (Of the bar)

Then you can return all instances of your wrapper as BAC.

The reason for this is properly phrased:

You can not enter between generic types with different types of criteria. Typical common types are not made part of the same heritage tree and hence are unrelated types.


Comments