The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
XNodeEqualityComparer::GetHashCode Method (XNode^)
.NET Framework (current version)
Returns a hash code based on an XNode.
Assembly: System.Xml.Linq (in System.Xml.Linq.dll)
Parameters
- obj
-
Type:
System.Xml.Linq::XNode^
The XNode to hash.
Implements
IEqualityComparer<T>::GetHashCode(T)The XNode implementation of GetHashCode is based on the referential identity of the node. This method computes a deep hash code based on the value of the node and all descendants. The hash code reflects all attributes and all descendent nodes.
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"));
This example produces the following output:
HashCode: 958CCD0
HashCode: AD26516B
Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: