Delegate.Equals(Object) Método

Definição

Determina se o objeto especificado e o delegado atual são do mesmo tipo e compartilham os mesmos destinos, métodos e lista de invocação.Determines whether the specified object and the current delegate are of the same type and share the same targets, methods, and invocation list.

public:
 override bool Equals(System::Object ^ obj);
public override bool Equals (object obj);
public override bool Equals (object? obj);
override this.Equals : obj -> bool
Public Overrides Function Equals (obj As Object) As Boolean

Parâmetros

obj
Object

O objeto a ser comparado com o delegado atual.The object to compare with the current delegate.

Retornos

Boolean

true se obj e o delegado atual têm os mesmos destinos, métodos e lista de invocação; caso contrário, false.true if obj and the current delegate have the same targets, methods, and invocation list; otherwise, false.

Exceções

O chamador não tem acesso ao método representado pelo representante (por exemplo, caso o método seja privado).The caller does not have access to the method represented by the delegate (for example, if the method is private).

Comentários

Se os dois delegados não forem do mesmo tipo, eles não serão considerados iguais.If the two delegates are not of the same type, they are not considered equal.

Importante

No .NET Framework versão 1,0 e 1,1, dois delegados foram considerados iguais se seus destinos, métodos e lista de invocação eram iguais, mesmo que os delegados fossem de tipos diferentes.In the .NET Framework version 1.0 and 1.1, two delegates were considered equal if their targets, methods, and invocation list were equal, even if the delegates were of different types.

Os métodos e destinos são comparados para igualdade da seguinte maneira:The methods and targets are compared for equality as follows:

  • Se os dois métodos que estão sendo comparados forem estáticos e forem o mesmo método na mesma classe, os métodos serão considerados iguais e os destinos também serão considerados iguais.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.

  • Se os dois métodos que estão sendo comparados forem métodos de instância e forem o mesmo método no mesmo objeto, os métodos serão considerados iguais e os destinos também serão considerados iguais.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.

  • Caso contrário, os métodos não são considerados iguais e os destinos também não são considerados iguais.Otherwise, the methods are not considered to be equal and the targets are also not considered to be equal.

Duas listas de invocação são consideradas idênticas somente se tiverem a mesma ordem e os elementos correspondentes das duas listas representarem o mesmo método e destino.Two invocation lists are considered identical only if they have the same order and the corresponding elements from the two lists represent the same method and target.

Aplica-se a

Confira também