VB.Net/Data Structure/Array ReDim — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:45, 26 мая 2010
ReDim an Array: new Array
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 Sub
End Class
ReDim: Make the array larger
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)
Next
End Sub
End Class