VB.Net/Data Structure/Array ReDim — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 19:40, 26 мая 2010
ReDim an Array: new Array
<source lang="vbnet"> 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
</source>
ReDim: Make the array larger
<source lang="vbnet"> 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
</source>