This topic has not yet been rated - Rate this topic

Array.IStructuralEquatable.GetHashCode Method

Returns a hash code for the current instance.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
int IStructuralEquatable.GetHashCode(
	IEqualityComparer comparer
)

Parameters

comparer
Type: System.Collections.IEqualityComparer
An object that computes the hash code of the current object.

Return Value

Type: System.Int32
The hash code for the current instance.

Implements

IStructuralEquatable.GetHashCode(IEqualityComparer)

This member is an explicit interface member implementation. It can be used only when the Array instance is cast to an IStructuralEquatable interface.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
This method throws IndexOutOfRangeException for non zero-based arrays.
  

using System;
using System.Collections;
using System.Collections.Generic;
internal static class ConsoleApplication{
private static void Main(){
try{
Array array=Array.CreateInstance(typeof(object),new[]{1},new[]{1});
((IStructuralEquatable)array).GetHashCode(EqualityComparer<object>.Default);
}catch(Exception e){
Console.WriteLine(e);
}
Console.ReadKey(true);
}
}

This method use only first element to generate hash code.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
internal static class MyClass{
private static void Main(){
Console.WriteLine(Enumerable.Range(0,1000000).Select(i=>new int[]{0,i}).Cast<IStructuralEquatable>().Select(ise=>ise.GetHashCode(EqualityComparer<int>.Default)).Distinct().Count());
Console.ReadKey();
}
}


This program always return 1.

P.S.
To get this form work properly in IE9, I have to opend developer tools (F12) and change document type to IE8.