Can I use Long for array indexing?
If no what could be done to manipulate large byte arrays (>32bit)?
Printable View
Can I use Long for array indexing?
If no what could be done to manipulate large byte arrays (>32bit)?
Hey cicatrix, As the Array class has a public property name LongLength I'd say you can.
I didn't test it though.
A workaround is to use a 2d array, for example MyArray(1, Integer.MaxValue). As you can see, this array has 2 "rows" and each row has integer.maxvalue elements. So it can hold twice as much data as a single 1d array. Now, to address an element given an int64 value as the index, you can use division and Mod to get the column and row index.
For example,
Code:Dim myarray(1, integer.maxvalue) as Byte
Dim longIndex as Int64 = 123456789
Dim column as integer = longindex Mod integer.maxvalue
Dim row as Integer = longindex \ integer.maxvalue
Dim myByte as Byte = myarray(row, column)
An array with more memory than my old laptop! Cool.