[API Proposal]: Implement IList<bool> on BitArray
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
### Background and motivation
`System.Collections.BitArray` implements the non-generic `ICollection`, but not the generic `ICollection`.
This makes it harder to use with LINQ.
Since `BitArray` already supports indexed access, implementing `IList` would also be a natural extension.
### API Proposal
```diff
namespace System.Collections;
public sealed class BitArray : ICloneable, System.Collections.ICollection
+ System.Collections.Generic.IList
{
}
```
### API Usage
```csharp
var bitArray = new BitArray(Enumerable.Range(0, 100).Select(static x => (x & 1) == 0).ToArray());
// foreach (bool item in bitArray.OfType())
foreach (bool item in bitArray)
{
Console.WriteLine(item ? "even" : "odd");
}
```
### Alternative Designs
_No response_
### Risks
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.