I need convert short to VariantType
My try (works not correct)
VariantType vt = (VariantType)vt;
So how can I convert short to VariantType?
(vb.net tag because VariantType is from Microsoft.VisualBasic)
Your code should be fine:
The following works perfectly:
short num = 4;
VariantType vt = (VariantType)num;
Console.WriteLine(vt);
And outputs "Single". This means that whatever problem you are having is not with the rough line of code you are using.
That having been said the actual line you are using (ie VariantType vt = (VariantType)vt;
is not going to work because the vt on the right hand side of the equation is invalid since it is unassigned (since you haven't finished declaring it). You should get a "Use of unassigned local vairable 'vt'" when you attempt to compile that.
I'm assuming that the line is a mistake but if not you should explain what you are actually trying to do with that line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With