Initially I was coding in C#.
Recently started with vb.net for my new project.
In C# reflection method, I used to create a object of generic type T
as such
T item= new T()
Can anybody please suggest how can I achieve the same thing in VB.Net
Dim item As new Type
is not compiling . Please help
If your generic type parameter is T
then:
Dim item As new T
Note though that you'll need to have the New
type constraint on the type parameter:
Public Class Foo(Of T As New)
Public Function Bar() As T
Dim item As New T
...
Return item
End Function
End Class
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