Delegate.RemoveAll(Delegate, Delegate) Method

Definition

Removes all occurrences of the invocation list of a delegate from the invocation list of another delegate.

public static Delegate RemoveAll (Delegate source, Delegate value);
public static Delegate? RemoveAll (Delegate? source, Delegate? value);

Parameters

source
Delegate

The delegate from which to remove the invocation list of value.

value
Delegate

The delegate that supplies the invocation list to remove from the invocation list of source.

Returns

A new delegate with an invocation list formed by taking the invocation list of source and removing all occurrences of the invocation list of value, if the invocation list of value is found within the invocation list of source. Returns source if value is null or if the invocation list of value is not found within the invocation list of source. Returns a null reference if the invocation list of value is equal to the invocation list of source, if source contains only a series of invocation lists that are equal to the invocation list of value, or if source is a null reference.

Exceptions

The delegate types do not match.

The caller does not have access to the method represented by the delegate (for example, if the method is private).

Remarks

If the invocation list of value matches a contiguous set of elements in the invocation list of source, then the invocation list of value is said to occur within the invocation list of source. If the invocation list of value occurs more than once in the invocation list of source, all occurrences are removed.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

See also