TryCast using an indirect type?

189 views Asked by At

Is there anyway to specify the object type for TryCast indirectly? An example of what I'd like to do (NOTE: This does not work - I get a syntax error saying "Type 'T' is not defined".)

Public Sub FOO()
    Dim SomObject As New Object

    For Each t As Type In Assembly.GetExecutingAssembly().GetTypes()
        TryCast(SomObject, t)
    Next

End Sub
0

There are 0 answers