CType in VB.NET with dynamic second parameter (type)
.net, casting, vb.net
Solution
Have you looked into the method CTypeDynamic()? The second parameter (ie: The Type) can be set dynamically. Great for when you are using Reflection.
For example:
CTypeDynamic(strValueToConvert, objTypeToConvertTo)
Problem
In VB.NET CType can be used to convert one type to another. ``` CType(expression,type) ``` I have the "expression" stored in an instance object class, say `"objExp"`. I have the "type" stored in an instance of Type class, say`"objType"`. I am trying `CType(objExp, objType)` I am getting compile error, how should I go about it ? "`objType`" is fetched and assigned at runtime.