Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C#

Index-based I/O ArrayList collection trong C#


ArrayList là ordered collection, index individually, alternative cho array.

Thuộc tính phổ biến:

Sr.NoThuộc tính & Mô tả
1Capacity - Sức chứa.
2Count - Số phần tử thực tế.
3IsFixedSize - Có fixed size không.
4IsReadOnly - Chỉ đọc không.
5Item - Lấy/gán phần tử tại index.

Ví dụ

using System;
using System.Collections;
namespace Demo {
    class Program {
        static void Main(string[] args) {
            ArrayList x = new ArrayList();
            x.Add(45); x.Add(53); x.Add(12); x.Add(88);
            Console.WriteLine("Capacity: {0}", x.Capacity);
        }
    }
}

Default capacity = 4.