Thread overview
Arrays of arrays question - answer needed quickly ...
Apr 10, 2003
Matthew Wilson
Apr 11, 2003
Walter
Apr 11, 2003
Matthew Wilson
April 10, 2003
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
"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
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.
>
>