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