I want to see if try cast can convert user entered answer to the type I have specified.
Here’s what I have:
Dim t as type = GetType(myType)
Dim ans = console.readline()
If TryCast(ans, t) <> Nothing Then ... 'Doesn't work`
In the example above the intelisense doesn’t even show t. How to make it work?
I guess you want to check if the user’s input is string, int, bool, date etc…
So if you want to convert the
readline()to a specific type, you can do the following:Dennis reply is also a good idea ..
Hope that helps!