I am trying to use reflections in VB.NET to handle types.
Public Function reflective(Of T)() As System.Type
Dim t_ As T = Nothing
Return t_.GetType()
End Function
Sub Main()
Dim nbr_type As Type = reflective(Of Int32)() 'Works fine
Console.Writeline("Number type is: " & nbr_type.Name) 'Works fine
Dim nbr As nbr_type = Nothing 'Fails 'nbr_type' is not declared. It may be inac...
'VB compiler completely fails to understand what I am trying to do
End Sub
How do I initialize a variable using System.Type
?
Aucun commentaire:
Enregistrer un commentaire