XNodeEqualityComparer.GetHashCode(XNode) Methode
Definition
public:
virtual int GetHashCode(System::Xml::Linq::XNode ^ obj);
public int GetHashCode (System.Xml.Linq.XNode obj);
override this.GetHashCode : System.Xml.Linq.XNode -> int
Public Function GetHashCode (obj As XNode) As Integer
Parameter
Gibt zurück
Ein Int32, das einen wertbasierten Hashcode für den Knoten enthält.A Int32 that contains a value-based hash code for the node.
Implementiert
Beispiele
Im folgenden Beispiel wird diese Methode verwendet, um einen Deep-Hashcode für eine XML-Struktur zu erhalten.The following example uses this method to get a deep hash code for an XML tree.
XElement xmlTree = new XElement("Root",
new XAttribute("Att1", 1),
new XAttribute("Att2", 2),
new XElement("Child1", 1),
new XElement("Child2", "some content")
);
XNodeEqualityComparer equalityComparer = new XNodeEqualityComparer();
Console.WriteLine("HashCode: {0}", equalityComparer.GetHashCode(xmlTree).ToString("X"));
xmlTree.Add(new XElement("NewChild", "new content"));
Console.WriteLine("HashCode: {0}", equalityComparer.GetHashCode(xmlTree).ToString("X"));
Dieses Beispiel erzeugt die folgende Ausgabe:This example produces the following output:
HashCode: 958CCD0
HashCode: AD26516B
Hinweise
Die XNode Implementierung von GetHashCode basiert auf der referenziellen Identität des-Knotens.The XNode implementation of GetHashCode is based on the referential identity of the node. Diese Methode berechnet einen Deep-Hashcode basierend auf dem Wert des Knotens und allen nachfolgenden Werten.This method computes a deep hash code based on the value of the node and all descendants. Der Hashcode reflektiert alle Attribute und alle Nachfolger Knoten.The hash code reflects all attributes and all descendent nodes.