C# 中 BitArray 類的 Length 屬性是什麼?


Length 屬性用於獲取或設定 BitArray 中的元素數。

我們的 BitArray。

BitArray arr = new BitArray( 5 );

使用 Length 屬性計算長度。

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

您可以嘗試執行以下程式碼以瞭解如何使用 BitArray 類的 Length 屬性。

示例

 即時演示

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

輸出

Count: 5
Length: 5

更新於:2020 年 6 月 23 日

68 次瀏覽

啟動你的職業生涯

完成課程,獲得認證

開始學習
廣告
© . All rights reserved.