หากต้องการค้นหาความยาวของอาร์เรย์ ให้ใช้เมธอด Array.Length()
ตัวอย่าง
เรามาดูตัวอย่างกัน −
using System;
class Program {
static void Main(){
int[] arr = new int[10];
// finding length
int arrLength = arr.Length;
Console.WriteLine("Length of the array: "+arrLength);
}
} ผลลัพธ์
Length of the array: 10
ด้านบนเรามีอาร์เรย์ -
int[] arr = new int[10];
ในการหาความยาว เราใช้เมธอด Length() -
int arrLength = arr.Length;