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

Thuộc tính Length của BitArray trong C#

Thuộc tính Length lấy hoặc thiết lập số phần tử trong BitArray.

BitArray:

BitArray arr = new BitArray(5);

Tính length:

Console.WriteLine("Length: {0}", arr.Length);

Ví dụ

using System;
using System.Collections;
public class Demo {
    public static void Main() {
        BitArray arr = new BitArray(5);
        Console.WriteLine("Count: {0}", arr.Count);
        Console.WriteLine("Length: {0}", arr.Length);
    }
}

Kết quả

Count: 5 Length: 5