Delegate.Inequality(Delegate, Delegate) 操作员

定义

确定指定的委托是否相等。Determines whether the specified delegates are not equal.

public:
 static bool operator !=(Delegate ^ d1, Delegate ^ d2);
public static bool operator != (Delegate d1, Delegate d2);
static member op_Inequality : Delegate * Delegate -> bool
Public Shared Operator != (d1 As Delegate, d2 As Delegate) As Boolean

参数

d1
Delegate

要比较的第一个委托。The first delegate to compare.

d2
Delegate

要比较的第二个委托。The second delegate to compare.

返回

如果 true 不等于 d1,则为 d2;否则为 falsetrue if d1 is not equal to d2; otherwise, false.

注解

如果两个委托的类型不同,或者具有不同的方法、不同的目标或不同的调用列表,则这两个委托被视为不相等。Two delegates are considered not equal if they are of different types, or have different methods, different targets, or different invocation lists.

如果两个委托的类型不同,则不会将它们视为相等。If the two delegates are not of the same type, they are not considered equal.

重要

在 .NET Framework 版本1.0 和1.1 中,如果两个委托的目标、方法和调用列表相等(即使这些委托属于不同类型),则将它们视为相等。In the .NET Framework version 1.0 and 1.1, two delegates are considered equal if their targets, methods, and invocation list were equal, even if the delegates were of different types.

比较方法和目标的相等性,如下所示:The methods and targets are compared for equality as follows:

  • 如果所比较的两个方法都是静态的,并且在同一类上是相同的方法,则这些方法被视为相等,并且目标也被视为相等。If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal.

  • 如果所比较的两个方法是实例方法,并且在同一对象上是相同的方法,则这些方法被视为相等,并且目标也被视为相等。If the two methods being compared are instance methods and are the same method on the same object, the methods are considered equal and the targets are also considered equal.

  • 否则,这些方法不会被视为相等,也不会将目标视为相等。Otherwise, the methods are not considered to be equal and the targets are also not considered to be equal.

如果两个调用列表具有不同的大小(如果它们的排序方式不同),或者一个列表中至少有一个元素表示一个方法或目标,而该方法或目标不同于另一个列表中其对应元素所表示的方法或目标,则两个调用列表不相等。Two invocation lists are not equal if they have different sizes, if they are ordered differently, or if at least one element from one list represents a method or target that is different from that represented by its corresponding element in the other list.

此运算符的等效方法是Delegate.Equals(Object)The equivalent method for this operator is Delegate.Equals(Object)

安全性

ReflectionPermission
当通过诸如InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])等机制后期绑定调用时。when invoked late-bound through mechanisms such as InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]). 关联的枚举:MemberAccessAssociated enumeration: MemberAccess

适用于

另请参阅