G
Guest
Hi I have trying to solve this but I can't understand why it's not working.
I want to cast a variable dynamically with a type that I pass truogh a string.
I am receiving a value and want to check if the type is correct before saving it to the XML.
I am getting the Type from xsd and pass this to a function to convert the newvalue to the proper type.
I want to avoid doing if statement to check for the type and then try to convert it.
This is an example my code.
Dim strType as string = "System.Int32"
Dim val as object
Dim type As Type = (type.GetType(strType))
val = CType(val, Type)
I have tried also passing a different object of type 'Type'
Is this possible?
Please help
I want to cast a variable dynamically with a type that I pass truogh a string.
I am receiving a value and want to check if the type is correct before saving it to the XML.
I am getting the Type from xsd and pass this to a function to convert the newvalue to the proper type.
I want to avoid doing if statement to check for the type and then try to convert it.
This is an example my code.
Dim strType as string = "System.Int32"
Dim val as object
Dim type As Type = (type.GetType(strType))
val = CType(val, Type)
I have tried also passing a different object of type 'Type'
Is this possible?
Please help