Expand|Select|Wrap|Line Numbers
- Imports System.ComponentModel
- Public Class level1Collection(Of T As level1Item)
- Inherits BindingList(Of T)
- Public Sub Load()
- Dim i As T = Me.AddNew
- End Sub
- End Class
- Public Class level2Collection(Of T As level2Item)
- Inherits level1Collection(Of level2Item)
- End Class
- Public Class level3Collection(Of T As level3Item)
- Inherits level2Collection(Of level3Item)
- End Class
- Public Class level4Collection(Of T As level4Item)
- Inherits level3Collection(Of level4Item)
- End Class
- Public Class level1Item
- End Class
- Public Class level2Item
- Inherits level1Item
- End Class
- Public Class level3Item
- Inherits level2Item
- End Class
- Public Class level4Item
- Inherits level3Item
- End Class
- Public Class Worker
- Sub New()
- Dim c As New level4Collection(Of level4Item)
- c.Load()
- End Sub
- End Class
'Basically I have 4 levels of inheritance, representing the core object all the way through the application level object. When I create "c" in the worker object. It creates a bindinglist(of level4items). When I call c.Load. which is inherited from the level1collection, the item that is created in the Me.AddNew is a level2item, not a level4item. Why is the base list creating in object from level 2 rather than level 4? The "type" of "Me" when I look in the level1collection is as follows
Expand|Select|Wrap|Line Numbers
- {Name = "level4Collection`1" FullName = "DemoApp.level4Collection`1[[DemoApp.level4Item, DemoApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"}
- System.RuntimeType: {Name = "level4Collection`1" FullName = "DemoApp.level4Collection`1[[DemoApp.level4Item, DemoApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"}
Thank you in advance, this is a simplified question to a rather large problem i'm facing.
Thanks.