Imports System
Class Program
Public Shared Sub AcceptAnyType(Of T)(ByVal x As T)
Dim s = TryCast(x, String)
If s IsNot Nothing Then
Console.WriteLine(s)
Else
Console.WriteLine("Not a string")
End If
End Sub
Public Shared Sub Main()
AcceptAnyType("A string")
AcceptAnyType(809)
End Sub
End Class
' run:
'
' A string
' Not a string
'