I want to create a generic list – but I want to specify the type at runtime – is there a way I can do this? using reflection perhaps?
Something like this…
Public Shared Sub create(ByVal t As Type)
Dim myList As New Generic.List(Of t)
End Sub
Thanks in advance
James
If callers know the type, you can make the method itself generic:
If callers do not know the type, you’ll have to resort to reflection – see the accepted answer to this question for more information.