METHOD

List<T>.RemoveAll

Mutates the list by removing every element satisfying the predicate and returns the number removed. The predicate should not mutate the list.

Formal Syntax & Structure

csharp syntaxcsharp
items.RemoveAll(predicate)

Working Example

Example Snippetcsharp
using System;using System.Collections.Generic;var items = new List<int> { 2, 0, 3, 0 };Console.WriteLine(items.RemoveAll(x => x == 0)); // 2
C# & .NET Reference