XNodeEqualityComparer.GetHashCode(XNode) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a hash code based on an XNode.
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
Parameters
Returns
A Int32 that contains a value-based hash code for the node.
Implements
Examples
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
Remarks
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.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기