Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

XNodeEqualityComparer.GetHashCode Method (XNode)

Returns a hash code based on an XNode.

Namespace:  System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)
public int GetHashCode(
	XNode obj
)

Parameters

obj
Type: System.Xml.Linq.XNode
The XNode to hash.

Return Value

Type: System.Int32
A Int32 that contains a value-based hash code for the node.

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.


StringBuilder output = new StringBuilder();
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();
output.Append("HashCode: " + equalityComparer.GetHashCode(xmlTree).ToString("X") + Environment.NewLine);
xmlTree.Add(new XElement("NewChild", "new content"));
output.Append("HashCode: " + equalityComparer.GetHashCode(xmlTree).ToString("X") + Environment.NewLine);

OutputTextBlock.Text = output.ToString();


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.