Thread overview | |||||
---|---|---|---|---|---|
|
April 10, 2003 Arrays of arrays question - answer needed quickly ... | ||||
---|---|---|---|---|
| ||||
In C# I declare arrays of arrays as byte[][] array1 = new byte[cAllocs][]; // Allocate all indexes for(j = 0; j < cAllocs; ++j) { array1[j] = new byte[ . . . ]; } In D, this does not work. It has to be byte[][] array1 = new byte[][cAllocs]; // Allocate all indexes for(j = 0; j < cAllocs; ++j) { array1[j] = new byte[ . . . ]; } Is this correct? It seems contradictory. A quick answer by anyone on this would be _greatly_ appreciated. :) Matthew |
April 11, 2003 Re: Arrays of arrays question - answer needed quickly ... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | "Matthew Wilson" <dmd@synesis.com.au> wrote in message news:b74opb$2u8$2@digitaldaemon.com... > In C# I declare arrays of arrays as > > byte[][] array1 = new byte[cAllocs][]; > > // Allocate all indexes > for(j = 0; j < cAllocs; ++j) > { > array1[j] = new byte[ . . . ]; > } > > In D, this does not work. It has to be > > byte[][] array1 = new byte[][cAllocs]; > > // Allocate all indexes > for(j = 0; j < cAllocs; ++j) > { > array1[j] = new byte[ . . . ]; > } > > Is this correct? It seems contradictory. > > A quick answer by anyone on this would be _greatly_ appreciated. :) It's correct. Note that the new syntax matches the declaration syntax. |
April 11, 2003 Re: Arrays of arrays question - answer needed quickly ... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Thanks "Walter" <walter@digitalmars.com> wrote in message news:b760fo$sr2$1@digitaldaemon.com... > > "Matthew Wilson" <dmd@synesis.com.au> wrote in message news:b74opb$2u8$2@digitaldaemon.com... > > In C# I declare arrays of arrays as > > > > byte[][] array1 = new byte[cAllocs][]; > > > > // Allocate all indexes > > for(j = 0; j < cAllocs; ++j) > > { > > array1[j] = new byte[ . . . ]; > > } > > > > In D, this does not work. It has to be > > > > byte[][] array1 = new byte[][cAllocs]; > > > > // Allocate all indexes > > for(j = 0; j < cAllocs; ++j) > > { > > array1[j] = new byte[ . . . ]; > > } > > > > Is this correct? It seems contradictory. > > > > A quick answer by anyone on this would be _greatly_ appreciated. :) > > It's correct. Note that the new syntax matches the declaration syntax. > > |
Copyright © 1999-2021 by the D Language Foundation