RemoveAll(Predicate match)
Removes all the elements that match the conditions defined by the specified predicate
.
- Returns the
number
of elements removed from theObservableCollection<T>
. - Exception match is
null
.
var collection = new ObservableCollection<int> { 1, 2, 3, 4, 5 };
var removed = collection.RemoveAll(x => x % 2 == 0); // 2 // { 1, 3, 5 }
RemoveAll()
Removes all the elements that match the conditions defined by the specified predicate
, and execute the specified action
on each element removed.
- Returns the
number
of elements removed from theObservableCollection<T>
. - Exception match is
null
or action isnull
.
var collection = new ObservableCollection<int> { 1, 2, 3, 4, 5 };
var removed = collection.RemoveAll(x => x % 2 == 0, x => Console.WriteLine("Delete: " + x));
// Delete: 2
// Delete: 4