C# 中 ArrayList 類中的 Count 屬性是什麼?
ArrayList 類中的 Count 屬性可統計 ArrayList 中的元素數量。
首先,向 ArrayList 新增元素 −
ArrayList arrList = new ArrayList(); arrList.Add(98); arrList.Add(55); arrList.Add(65); arrList.Add(34);
然後獲取 array list 中的數量 −
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