Can you pass a "type" as an argument?

casting, types, vb.net

Solution

Yes. There is System.Type. You may actually want to do a Generic however.

Function SomeFunction(Of T)(obj As Object) As T
    '' Magic
End Function

Problem

I want to do something like the following in VB.NET, is it possible? ``` Function task(value as Object, toType as Type) Return DirectCast(value, toType) End Function ```

Original source