Get length of array C#
Hello everyone,
I'm trying to obtain the length of an array using c#. So I have this: public Transform[] waypoints; Which I fill with empty objects that will be used as a path. I want to get the length of this array so that I will be able to isolate it in a variable and use it afterwards. But, strangely, I cannot obtain the length of my array. I can't find a method which would give me the length of my array like this:
private int waypointsNumber;
waypointsNumber = waypoints.GetLength();
Is there a method or a way in c# to obtain this value?
Answer by $$anonymous$$ · Apr 20, 2012 at 04:17 PM
Actually, you don't have to use a method, but read a "Property" of the array :
waypointsNumber.Length
more about properties in C# : http://msdn.microsoft.com/en-us/library/x9fsa0sw.aspx
Answer by fafase · Apr 20, 2012 at 04:15 PM
It would be waypoints.Length;
I am no familiar with Unity C# But that sounds like it
Your answer
Follow this Question
Related Questions
Getting variables that from an array of scripts 2 Answers
Cant define array from other script 0 Answers
Checking if an instance of a Script saved in 3d array is null 1 Answer
Get Vector3s in range 1 Answer