What’s all this then?

This might look strange to a C programmer:

Dim I(10) As Integer
Console.WriteLine(I.Length)
Dim J(I.Length - 1) As Integer
Console.Write(J.Length)

This will give the output 11 and 11. The array named I has 11 elements because the last index (10) is given when the array is created. The array named J has 11 elements bacause Length (11) – 1 equals 10, and a 0-based array with last element 10 gives you 11 elements. Confusing.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *