最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
vb.net数组(长度,赋值 )
时间:2022-06-25 05:34:22 编辑:袖梨 来源:一聚教程网
下面三个关于vb.net数组操作实例主要对数据元素,数据长度,数据改变值来讲了,下面来看三个实例代码
增加数据长度
imports system
public class mainclass
shared sub main()
'declare an array
dim strfriends(4) as string'populate the array
strfriends(0) = "r"
strfriends(1) = "b"
strfriends(2) = "s"
strfriends(3) = "s"
strfriends(4) = "k"redim preserve strfriends(6)
strfriends(5) = "m"
strfriends(6) = "j"for each strname as string in strfriends
system.console.writeline(strname)
nextend sub
end class
重新给数据元素指定值
imports system
public class mainclass
shared sub main(byval args as string())
dim friends() as string = {"a", "b", "c","d", "e"}' make friends bigger!
redim friends(6)
friends(5) = "f"
friends(6) = "g"
addfriendstolist(friends)
end sub
shared sub addfriendstolist(byval friends() as string)
dim friendname as string
for each friendname in friends
console.writeline("[" & friendname & "]")
next
end subend class
改变数据长度
imports system
public class samplesarray
public shared sub main()
dim myarr as string() = {"the", "quick", "brown", "fox", "jumps教程", "over", "the", "lazy", "dog"}printindexandvalues(myarr)
array.resize(myarr, myarr.length + 5)
printindexandvalues(myarr)
array.resize(myarr, 4)
printindexandvalues(myarr)
end sub 'main
public shared sub printindexandvalues(myarr() as string)
dim i as integer
for i = 0 to myarr.length - 1
console.writeline("[{0}] : {1}", i, myarr(i))
next i
end subend class
相关文章
- 死亡搁浅2次要订单No.100 将拆解的步枪送到独行指挥官手上全流程攻略 09-06
- 死亡搁浅2怎么开启照明 闪光灯开启方法 09-06
- 超级忍反攻的斩击怎么下载 完整中文版获取指南 09-06
- 死亡搁浅2怎么使用VR培训室 09-06
- 超级忍反攻的斩击有手机版吗 移动端游玩指南 09-06
- 死亡搁浅2怎么提高波特等级 提高波特等级的方法 09-06