How to calculate the size of hole array
How to get the size of hole array including all elements means total size of array.....?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Amit ChoudharyRank #145 · 15.8K reputationPosted Feb 10, 2011, 2:11 AM EST
Use the function GetUpperBoaund(
Thanks...
Soft CornerRank #1,221 · 1.5K reputationPosted Feb 10, 2011, 2:12 AM EST
Using array Length property ,
If it's a one-dimensional array
a,will give then number of elements of
a.If
bis a rectangular multi-dimensional array (for example,int[,] b = new int[3, 5];)will give the number of dimensions (2), and
will get the length of any given dimension (0-based indexing for the dimensions - so
b.GetLength[0]is 3 andb.GetLength[1]is 5).See System.Array Members for more info.
, there is a concept of a "jagged array", which is really nothing more than a single-dimensional array of (typically single-dimensional) arrays. For example, one could have
int[][] c = new int[][3]; c[0] = new int[] {1, 2, 3}; c[1] = new int[] {3, 14}; c[2] = new int[] {1, 1, 2, 3, 5, 8, 13};Note that the 3 members of
call have different lengths. In this case, as beforec.Lengthwill indicate the number of elements ofc, (3) andc[0].Length,c[1].Length, andc[2].Lengthwill be 3, 2, and 7, respectively.Smart LuckyRank #2,625 · 531 reputationPosted Feb 10, 2011, 10:24 PM EST