如何找到 C# 中陣列的長度?
要查詢陣列的長度,請使用 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;
廣告