共用方式為


XNodeEqualityComparer 建構函式

定義

初始化 XNodeEqualityComparer 類別的新執行個體。

public:
 XNodeEqualityComparer();
public XNodeEqualityComparer ();
Public Sub New ()

範例

下列範例會使用此類別來判斷兩個節點是否相等。

XElement xmlTree1 = new XElement("Root",  
    new XAttribute("Att1", 1),  
    new XAttribute("Att2", 2),  
    new XElement("Child1", 1),  
    new XElement("Child2", "some content")  
);  
XElement xmlTree2 = 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(equalityComparer.Equals(xmlTree1, xmlTree2));  
xmlTree2.Add(new XElement("NewChild", "new content"));  
Console.WriteLine(equalityComparer.Equals(xmlTree1, xmlTree2));  

這個範例會產生下列輸出:

True  
False  

適用於

另請參閱