P. 1
Deep_C.pdf

Deep_C.pdf

|Views: 36|Likes:
Published by dhananjayan89
Uploaded from Google Docs
Uploaded from Google Docs

More info:

Published by: dhananjayan89 on Jun 25, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

10/27/2011

pdf

text

original

Arrays in C# are of reference type and mostly follow Java style. C# has the best

of both worlds by having the regular C array which is referred in C# as rectangular array

and also have Java style ‘jagged’ arrays.

int regular2DArray [ , ];

// this is a rectangular (C like) array.

int jagged2DArray [] [];

// this is a ‘jagged’ array

In C as we have seen, ‘ragged’ or ‘jagged’ arrays can be implemented by having a

pointer array and allocating memory dynamically for each array. The same idea is

followed here except that instead of pointer type, reference type is used. This makes

optimal use of space sometimes since the sub-arrays may be of varying length. The

compromise is that additional indirections are needed to refer to access sub-arrays. This

access overhead is not there in rectangular array since all the sub-arrays are of same size.

When more than on way of representation is supported then at some point of time

the user will require switching from one representation to another. Here to convert from

one array type to another, techniques called as boxing and un-boxing are used.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->