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:
Public Shared Sub create(Of t)()
Dim myList As New Generic.List(Of t)
End Sub
If callers do not know the type, you'll have to resort to reflection - see the accepted answer to this question for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With