ListBase with unknown generic

  • Thread starter Thread starter mytchewbacca
  • Start date Start date
M

mytchewbacca

I would like to create a base class that inherits List(of X) where X
would be determined by the class inheriting the base.


ie


Public MustInherit Class ListBase : Inherits List(Of ?)
Protected Sub common()
//This code would not be specific to the list type, as that
could be a problem
End Sub
End Class


Public Class Words : Inherits ListBase(Of String)
...
End Class


Public class Numers : Inherits ListBase(Of integer)
...
End Class


I realize there are ways around this but I was just wondering


1. Is this possible?
2. Would this be a poor design? If so, what would be the
recommended strategy?

C# or VB.net
 
I have found a solution to question 1.
Is this possible? Yes

Public Class ListBase(Of itemType) : Inherits List(Of itemType)

End Class

But would still be interested in an answer to question 2.
 
Back
Top