XNodeEqualityComparer.IEqualityComparer.Equals(Object, Object) 方法


比较两个节点的值。Compares the values of two nodes.

 virtual bool System.Collections.IEqualityComparer.Equals(System::Object ^ x, System::Object ^ y) = System::Collections::IEqualityComparer::Equals;
bool IEqualityComparer.Equals (object x, object y);
abstract member System.Collections.IEqualityComparer.Equals : obj * obj -> bool
override this.System.Collections.IEqualityComparer.Equals : obj * obj -> bool
Function Equals (x As Object, y As Object) As Boolean Implements IEqualityComparer.Equals



要比较的第一个 XNodeThe first XNode to compare.


要比较的第二个 XNodeThe second XNode to compare.



如果节点相等,则为 true;否则为 falsetrue if the nodes are equal; otherwise false.



以下条件确定两个节点是否相等:The following criteria determine whether two nodes are equal:

  • null节点与另一个节点相等, null 但不等于非 null 节点。A null node is equal to another null node but unequal to a non-null node.

  • XNode不同类型的两个对象从不相等。Two XNode objects of different types are never equal.

  • 如果两个 XText 节点包含相同的文本,则这两个节点相等。Two XText nodes are equal if they contain the same text.

  • 如果两个 XElement 节点具有相同的标记名称、具有相同值的相同属性集, (忽略注释和处理指令) ,则它们包含两个成对相等内容节点的 equa 长度序列。Two XElement nodes are equal if they have the same tag name, the same set of attributes with the same values, and (ignoring comments and processing instructions), contain two equa-length sequences of pairwise equal content nodes.

  • 如果两个对象的根节点相等,则这两个 XDocument 对象相等。Two XDocument objects are equal if their root nodes are equal.

  • 如果两个 XComment 节点包含相同的注释文本,则这两个节点相等。Two XComment nodes are equal if they contain the same comment text.

  • 如果两个 XProcessingInstruction 节点具有相同的目标和数据,则这两个节点相等。Two XProcessingInstruction nodes are equal if they have the same target and data.

  • 如果两个 XDocumentType 节点具有相同的名称、公用 ID、系统 ID 和内部子集,则这两个节点相等。Two XDocumentType nodes are equal if the have the same name, public ID, system ID, and internal subset.