GameObject[,] myArray = new GameObject[3, 4]; int length = myArray.GetLength(0); Console.WriteLine(length); //output: 3
using System; public class Program { public static void Main() { GameObject[,] myArray = new GameObject[2, 3]; int rowLength = myArray.GetLength(0); int colLength = myArray.GetLength(1); Console.WriteLine("Number of rows: " + rowLength); Console.WriteLine("Number of columns: " + colLength); } }In this example, we initialize a two-dimensional `GameObject` array with 2 rows and 3 columns. We then retrieve and print the length of both dimensions of the array, which are 2 and 3 respectively. Package/Library: This method is part of the UnityEngine namespace in the Unity Engine package.