เพื่อหาความยาวของอาร์เรย์ ให้ใช้คุณสมบัติ Array.Length (หรือ arr.Length)
ตัวอย่าง
using System;
class Program {
static void Main() {
int[] arr = new int[10];
int arrLength = arr.Length;
Console.WriteLine("Length of the array: " + arrLength);
}
}
ผลลัพธ์
Length of the array: 10
อธิบาย: เรามีอาร์เรย์ int[] arr = new int[10]; ใช้ Length เพื่อหาความยาว