Is there a way to convert a variable from 1 type to another type that you
determine at runtime? I'm trying to pull a value from a ListDictionary's
key. The datatype of that key must be identical to pull that value. I have a
property to pull this value based on the key supplied, but I am using an
object type on my parameter. I want to do a ctype() on the lookUpListKey and
change it to the correct data type so that it's corresponding value will be
pulled. Since lookUpListKey could be a byte, integer, string, etc., I don't
know what to change it to unless I do a getType, but the Ctype function
doesn't allow there to be an expression in the 2nd parameter. Anyway around
this?
Ex: This does not work using the getType() in the 2nd parameter for ctype()
Public Shared ReadOnly Property ListItemValue(ByVal lookUpListName As
String, ByVal lookUpListKey As Object) As String
Get
Return CType(HttpContext.Current.Cache(lookUpListName),
ListDictionary).Item(Ctype(lookUpListKey,lookUpLis tKey.getType())).ToString(
)
End Get
End Property