Answer the following questions about the following initialized array: Dim strSeafood(8) as String.
a. Assign Oysters to the first array location. What is the index number?
b. Assign Lobster to the fourth location in the array. What would the assignment statement look like?
c. What value does strSeafood.Length have?
d. How many types of seafood can this array hold?
e. What would happen if you assigned strSeafood(9) = “Red Snapper”?
Module Module1
Sub Main()
Dim strSeafood(8) As String
'a. Assign Oysters to the first array location. What is the index number? Answer: ZERO
strSeafood(0) = "Oysters"
'b. Assign Lobster to the fourth location in the array. What would the assignment statement look like?
strSeafood(3) = "Lobster"
'c. What value does strSeafood.Length have? Answer: 9
Console.WriteLine(strSeafood.Length.ToString())
'd. How many types of seafood can this array hold? Answer: one type String
'e. What would happen if you assigned strSeafood(9) = “Red Snapper”?
'Answer:An IndexOutOfRangeException exception is thrown when an invalid index is used to access a member of an array or a collection
strSeafood(9) = "Red Snapper"
Console.ReadLine()
End Sub
End Module
Comments
Leave a comment