C# 中 ArrayList 類中的 Count 屬性是什麼?
ArrayList 類的 Count 屬性計算 ArrayList 中的元素數。
首先,向 ArrayList 新增元素 −
ArrayList arrList = new ArrayList(); arrList.Add(98); arrList.Add(55); arrList.Add(65); arrList.Add(34);
然後,計算陣列列表的計數 −
arrList.Count
以下是使用 C# 實現 Count 屬性的程式碼 −
示例
using System;
using System.Collections;
class Demo {
public static void Main() {
ArrayList arrList = new ArrayList();
arrList.Add(98);
arrList.Add(55);
arrList.Add(65);
arrList.Add(34);
Console.WriteLine("Count = " + arrList.Count);
}
}輸出
Count = 4
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP