dotnet / dotnet/runtime

[API Proposal]: Add RemoveWhere to all relevant collections

Open
#122,771 4 comments 0 reactions 0 assignees View on GitHub
api-suggestion area-System.Collections
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Background and motivation

Please add 'RemoveWhere' to all relevant collections. RemoveWhare is extremely useful when doing clean up than iterating and removing, which also is very problematic using 'foreach'.

### API Proposal

```csharp
namespace System.Collections.Generic;

public class ICollection : .........
{
...
public int RemoveWhere (Predicate match)
...
}
```

### API Usage

```csharp
var list = new List();
list.RemoveWhere (x => x.Status == "Dead");
```

### Alternative Designs

_No response_

### Risks

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.