Re: [Vala] how to access the length attribute of multi dimensional arrays?
- From: Rob Taylor <rob taylor codethink co uk>
- To: Seth Hoenig <seth a hoenig gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] how to access the length attribute of multi dimensional arrays?
- Date: Sun, 04 Jul 2010 19:17:01 +0100
On 02/07/10 00:26, Seth Hoenig wrote:
So if I pass a matrix to a function (or any multidimensional array), I can
only seem to access the .length attribute of the first dimension. Is there a
way to access the .length attributes of the other dimensions of the array?
public Something(int[,] arr)
{
_n_rows = arr.length;
_n_cols = arr[0, ].length; // no compile :(
}
In the example above, I can't seem to find a way to find out how many
columns are in my matrix.
If I recall correctly, multidimensional arrays have an arrayed length
member - i.e.
public Something(int[,] arr)
{
_n_rows = arr.length[0];
_n_cols = arr.length[1];
}
HTH,
Rob
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
--
Rob Taylor, Managing Director, Codethink Ltd. - http://codethink.co.uk
Twitter: #robtaylor78 - LinkedIn: http://www.linkedin.com/in/robtaylor78
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]