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  

适用于

另请参阅