Undetermined type conversion in VB.NET 2008
Posted
by user337501
on Stack Overflow
See other posts from Stack Overflow
or by user337501
Published on 2010-05-11T18:29:31Z
Indexed on
2010/05/11
18:34 UTC
Read the original article
Hit count: 278
I figured this would be a quick google, but extensive searching hasnt yielded any results. Everything about type conversion seems to dance around this concept.
I want to get the type of variable "a", and make a new variable named "b" of that type. Otherwise I could have "a" as a type already declared and "b" simply as an Object, then try to cast "b" to the type of "a".
Dim a As Integer
Dim b As Whatever a Is
OR
TryCast(b, Whatever a Is)
I would also like to make the conversion using a variable representation of the type, but cant find info on how to do that either.
Sorta like:
Dim a As Integer
Dim b As Object
Dim t As Type
t = a.GetType()
TryCast(b, t)
Realizing I'm completely misusing TryCast here, I'm mostly trying to get my goal across. I figured it would be an easy quick thing to do but I cant really find any specific info on it. Any ideas?
© Stack Overflow or respective owner