This post was inspired by this forumthread on VBIB (dutch).
Some people seem to forget that arrays in VB.Net are 0-based. Meaning that this.
vbnet
Dim array1(0) As Integer
Console.WriteLine(array1.Count)
This instantiates the array with one element in it. But there is nothing stopping you from creating an array with 0 elements in it. Appart from the fact that it seems a bit unnatural.
vbnet
Dim array1(-1) As Integer
Console.WriteLine(array1.Count)
And why would you do that? Why not just do.
vbnet
Dim array1() As Integer
Console.WriteLine(array1.Count)
Because the above will give you a NullReferenceException, that’s why.
So doing the unnatural is perhaps the way to go if you really need an array that has no predefined size.