What is the Length property of BitArray class in C#?


The length property is used to gets or sets the number of elements in the BitArray.

Our BitArray.

BitArray arr = new BitArray( 5 );

To calculate the length, use the length property.

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

You can try to run the following code to learn how to work with Length property of BitArray class.

Example

 Live Demo

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 );
   }
}

Output

Count: 5
Length: 5

Updated on: 23-Jun-2020

61 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements