Hello,
I have a base class (ex: Class1) containing a list of another base class (ex: ClassA). Each child class of first base class (ex: Class1AA, Class1AB,..) containing a list of child class of second base class (ex: ClassAA, ClassAB,...)
The client must never know which child class is using, then i don't think i can use generic for my bases classes.
I try something like this and many more, but i always received errors..
Imports System.Collections.Generic
Public Class Client
Public Sub DoAction(obj as Class1)
For Each item as ClassA in obj.ItemList
...
Next
End Sub
End Class
Public MustInherit Class Class1
Public MustOverride ReadOnly Property ItemList() As IList(Of ClassA)
End Class
Public Class Class1AA
Inherits Class1
Public Overrides ReadOnly Property ItemList() As IList(Of ClassA)
Get
Return New List(Of ClassAA)
End Get
End Property
End Class
Public Class Class1AB
Inherits Class1
Public Overrides ReadOnly Property ItemList() As IList(Of ClassA)
Get
Return New List(Of ClassAB)
End Get
End Property
End Class
Public Class ClassA
End Class
Public Class ClassAA
Inherits ClassA
End Class
Public Class ClassAB
Inherits ClassA
End Class
Thanks for your help