Delegate.Remove(Delegate, Delegate) 方法

定义

从一个委托的调用列表中移除另一个委托的最后一个调用列表。

C#
public static Delegate Remove(Delegate source, Delegate value);
C#
public static Delegate? Remove(Delegate? source, Delegate? value);

参数

source
Delegate

委托,将从中移除 value 的调用列表。

value
Delegate

委托,它提供将从其中移除 source 的调用列表的调用列表。

返回

一个新委托,其调用列表的构成方法为:获取 source 的调用列表,如果在 value 的调用列表中找到了 value 的调用列表,则从中移除 source 的最后一个调用列表。 如果 sourcenull,或在 value 的调用列表中没有找到 value 的调用列表,则返回 source。 如果 value 的调用列表等于 source 的调用列表,或 source 为空引用,则返回空引用。

例外

委托类型不匹配。

调用方不能访问由委托表示的方法(例如,在方法为私有方法的情况下)。

注解

如果 的 value 调用列表与 的调用列表中的 source一组连续的元素匹配,则 的调用列表 value 据说出现在 的 source调用列表中。 如果 的调用列表 value 在 的调用列表中 source多次出现,则删除最后一个匹配项。

适用于

产品 版本
.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, 10
.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

另请参阅