Array.IStructuralEquatable.GetHashCode Method
Returns a hash code for the current instance.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- comparer
- Type: System.Collections.IEqualityComparer
An object that computes the hash code of the current object.
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.
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.
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);
}
}
- 12/9/2011
- PetSerAl
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.