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.

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll:

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Comments

Important information: If you have not commented before, your comment will be reviewed before it is published. This means that you will not see it immediately, but I have received it. This is not because I want to filter comments, but because I want to prevent spam and advertising.

Leave a Reply

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