IHashCodeProvider.GetHashCode(Object) Método

Definição

Retorna um código hash para o objeto especificado.Returns a hash code for the specified object.

public:
 int GetHashCode(System::Object ^ obj);
public int GetHashCode (object obj);
abstract member GetHashCode : obj -> int
Public Function GetHashCode (obj As Object) As Integer

Parâmetros

obj
Object

O Object para o qual um código hash deve ser retornado.The Object for which a hash code is to be returned.

Retornos

Int32

Um código hash para o objeto especificado.A hash code for the specified object.

Exceções

O tipo de obj é um tipo de referência e obj é null.The type of obj is a reference type and obj is null.

Comentários

O valor de retorno desse método não deve persistir por dois motivos.The return value from this method must not be persisted for two reasons. Primeiro, a função de hash de uma classe pode ser alterada para gerar uma distribuição melhor, Renderizando quaisquer valores da função de hash antiga inútil.First, the hash function of a class might be altered to generate a better distribution, rendering any values from the old hash function useless. Em segundo lugar, a implementação padrão dessa classe não garante que o mesmo valor será retornado por instâncias diferentes.Second, the default implementation of this class does not guarantee that the same value will be returned by different instances.

Aplica-se a

Confira também