virtual public void Clear() { // Only clear items of this type // that match the predicate. var items = _RealObject .OfType <TNew>() .ToArray(); foreach (var item in items) { _RealObject.Remove(item); } }
/// <summary> /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1" />. /// </summary> public void Clear( ) { // Only clear items of this type // that match the predicate. TNew[] items = _realObject .OfType <TNew>( ) .Where(_predicate) .ToArray( ); foreach (TNew item in items) { _realObject.Remove(item); } }