Share via


XNodeEqualityComparer.GetHashCode(XNode) 메서드

정의

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

매개 변수

obj
XNode

해시할 XNode입니다.

반환

Int32

노드에 대한 값 기반 해시 코드가 들어 있는 Int32입니다.

구현

예제

다음 예제에서는 이 메서드를 사용하여 XML 트리에 대한 심층 해시 코드를 가져옵니다.

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"));  

이 예제는 다음과 같은 출력을 생성합니다.

HashCode: 958CCD0  
HashCode: AD26516B  

설명

구현은 XNode 노드의 GetHashCode 참조 ID를 기반으로 합니다. 이 메서드는 노드 및 모든 하위 항목의 값에 따라 심층 해시 코드를 계산합니다. 해시 코드는 모든 특성과 모든 하위 노드를 반영합니다.

적용 대상

추가 정보