✔ 最佳答案
a)write a seclaration statement(dim statement) to store the four team members'names(A,B,C,D) into an array name team(4)
Dim team() As String = new String(4){"A","B","C","D"}
alternatively, if you want to split into more lines, you can write: Dim team(4) As Sring
'declaring an array
sport(0) = "A"
sport(1) = "B"
sport(2) = "C"
sport(3) = "D" Since array indices start at 0, the maximum index is one lower than the size of the array
b)fi we want to increase the size of the array to six(i.e team(6))after the above statement is declared,what should we do?
Writedown a statement to achieve this without preserving its original contents, and also a statement that can preservethe original contents
The Redim command increases the size of the existing array. All existing elements are lost. ReDim team(6) as String The old array team(4) is no longer referenced, and is put on the list for garbage collection.
To preserve the existing values, we need the keyword Preserve" ReDim Preserve team(25) as String
c)write a declaration statement for team() without specifying an upper bound for it
Dim team() as String will declare the variable team as an array without specifying an upper bound. This allows the specification of an upper bound during execution depending on the problem requirements, such as: team()=new String(20)