读书人

这两个声明数组的方式有什么不同?解决

发布时间: 2012-01-01 23:10:55 作者: rapoo

这两个声明数组的方式有什么不同?
dim a() as integer = {1,2,3,4,5}

Dim a As Integer() = {1, 2, 3, 4, 5}

dim a as integer() = new integer() {1,2,3,4,5}

如果运行:
msgbox(a.gettupperbound(0))

结果都是4
请问以上两个声明数组的方法有什么不同
谢谢!

[解决办法]
呵呵,第一个应该很好理解的,第二个也应该是声明一个integer数组,不过可能直接构建的integer数组,integer类型的一个特例,a是他的引用地址,类似c语言的数组首引用吧,只是猜测,没研究过,或者integer()是integer类型的空构造函数?
[解决办法]
没有不同,两种声明方法生成的il是相同的。

if "il相同 " then "dim xx as yy() = dim xx() as yy "

读书人网 >VB Dotnet

热点推荐