Correct! it MIGHT overflow! ... let's see WHEN?
So, a Long data type is 32 bits, but we are using a signed integer, so 31 bits, and that is 2,147,483,648... those are
array items...
Now lets see how much memory you would need to store that many items (so that you get the overflow)
So, internally, each item is a pointer to another location in the memory (basically an array of pointers) each one pointing to a string structure (a BSTR, I can't find anywhere the actual structure of BSTR),
similar to this one, and that structure is 12 bytes (on a x86 processor) (and there is another pointer to the actual string... and lets say on average the string is 10 bytes? so let's do the math...
2^31 * 4 * 12 * 10 = 1.0307922e+12
that number is in bytes... so let's convert that into GBytes:
(2^31 * 4 * 12 * 10) / 1073741824 = 960 GBytes
So... you will get an overflow error if the total memory your array takes is approximately (with a few assumptions) 960 GBytes that has to be stored in RAM (by the way)... and again... this is if your average string is 10 bytes long... and since all strings are unicode, that means 5 characters each string
So... in conclusion... let's add another operation to the loop to slow it down, because we might get an overflow sometime in the future when computers will have a few terabytes of RAM... it might not be that much far away...
But.... good catch though
[Edit]... if you port this code to VB.net then the Long data type is 64 bits.... so.... do you still think you might get an overflow?