cornelius1729 Posted January 26, 2009 Posted January 26, 2009 Is there a simple way to retrieve the size of an array? For example: If I declare a two dimensional integer array, int[,] ia = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; then I would like something like ia.Size, or ia.Dimensions that returns an integer array containing 3,2. ia.Rank reveals that there are two dimensions, and ia.Length tells me that there are 6 elements, but I can't find what I want. Thanks in advance. Quote
cornelius1729 Posted January 26, 2009 Author Posted January 26, 2009 Okay, I new it had to be obvious: you can iterate over the dimensions using GetLength, e.g. int[] dims = new int[ia.Rank]; for(int i=0; i<ia.Rank; ++i) { dims = ia.GetLength(i); } Simple. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.