如何使 BitArray 只读?

How to make a BitArray readonly?

如何使 System.Collection.BitArray 只读?我找了下面的但是还没有成功...

我错过了什么?

(我正在使用 .NET 4.8 到 6.0,多目标)

来自documentation of BitArray.IsReadOnly

This property is always false.

BitArray implements the IsReadOnly property because it is required by the System.Collections.IList interface.

我觉得这个解释有点奇怪,因为 BitArray 似乎没有实现 IList,只有 ICollection。但这是给出的解释。

如果您特别需要只读的 bitArray,一个选项可能是创建您自己的 class 或包装器。