Cet article a fait l'objet d'une traduction manuelle. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. |
Traduction
Source
|
Type.GetHashCode, méthode
.NET Framework 4
Retourne le code de hachage pour cette instance.
Assembly : mscorlib (dans mscorlib.dll)
Cette méthode substitue Object.GetHashCode.
L'exemple suivant affiche le code de hachage de la classe System.Windows.Forms.Button.
using System; using System.Security; using System.Reflection; class FieldsSample { public static void Main() { Type myType = typeof(System.Net.IPAddress); FieldInfo [] myFields = myType.GetFields(BindingFlags.Static | BindingFlags.NonPublic); Console.WriteLine ("\nThe IPAddress class has the following nonpublic fields: "); foreach (FieldInfo myField in myFields) { Console.WriteLine(myField.ToString()); } Type myType1 = typeof(System.Net.IPAddress); FieldInfo [] myFields1 = myType1.GetFields(); Console.WriteLine ("\nThe IPAddress class has the following public fields: "); foreach (FieldInfo myField in myFields1) { Console.WriteLine(myField.ToString()); } try { Console.WriteLine("The HashCode of the System.Windows.Forms.Button type is: {0}", typeof(System.Windows.Forms.Button).GetHashCode()); } catch(SecurityException e) { Console.WriteLine("An exception occurred."); Console.WriteLine("Message: "+e.Message); } catch(Exception e) { Console.WriteLine("An exception occurred."); Console.WriteLine("Message: "+e.Message); } } }
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.