Version: 2017.2

설명

The length property of the array that returns or sets the number of elements in array.

The Array.length controls how JS can access or set the size of the array. The example JS script below shows that the length property of the array starts with a lower-case "l".

Note: This page includes a c-sharp script example. The use of two array styles and their use of length are shown.

// C# array length example
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { // use string array approach string[] names = new string[] {"Hello", "World", "Really"};

foreach (string s in names) { print("user is: " + s); }

print("length is: " + names.Length);

// use ArrayList approach ArrayList arr = new ArrayList(); arr.Add("Hello"); arr.Add("World");

// ArrayList uses Count instead of Length print(arr.Count); } }