ListBase with unknown generic

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
 
M

mytchewbacca

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top