有关类型转换的帮助 [英] Help on Type Casting
本文介绍了有关类型转换的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这不起作用?
Why isn''t this working ?
Dim x As Integer = 90
Dim temp As Object
Dim typ As Type = Type.GetType("System.String")
temp = CType(x, Typ)
它在Ctype函数的第二个参数中显示错误. :doh:
It shows error in 2nd argument of Ctype function. :doh:
推荐答案
CType出现错误,因为x(整数)和typ( Type !!! )之间没有有效的转换.您可能想使用CType(x,String)甚至CType(x,Object).
无论如何,为什么不使用x.ToString()?
干杯
CType gives the error because there is no valid conversion between x (Integer) and typ(Type!!!). You would want to use CType(x, String) or even CType(x, Object).
Anyhow why not use x.ToString()?
Cheers
这篇关于有关类型转换的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文