- Home /
Question by
Tofudude624 · Jan 30, 2012 at 11:43 PM ·
arrayint
Finding the number of elements in a sub-array?
Hello. If I have a multi-dimensional array, how can I find the length of one of the first dimension arrays(in this case, I want to find how many elements are in the first element of the array) ?
var TestArray : int[,];
var TestVar : int;
function Start (){
TestVar=TestArray[0].length;
}
Thanks
Comment
What's wrong with what you've written ? Except that you can have a null exception if the TestArray is null, it should works.
Best Answer
Answer by syclamoth · Jan 31, 2012 at 12:14 AM
Almost right- what you want is this:
TestVar = TestArray.GetLength(0);
Your answer
Follow this Question
Related Questions
get int based on 3 ints 0 Answers
JS: Array index not taking array.length as valid int? 2 Answers
Calculating the lowest number 3 Answers
Best Way to Load 10^8 int Array in Unity/C#? 1 Answer
Converting a string to an int 2 Answers