LINQ to XML Annotations

Annotations in LINQ to XML enable you to associate any arbitrary object of any arbitrary type with any XML component in an XML tree.

To add an annotation to an XML component, such as an XElement or XAttribute, you call the AddAnnotation method. You retrieve annotations by type.

Note that annotations are not part of the XML infoset; they are not serialized or deserialized.


You can use the following methods when working with annotations:

Method Description


Adds an object to the annotation list of an XObject.


Gets the first annotation object of the specified type from an XObject.


Gets a collection of annotations of the specified type for an XObject.


Removes the annotations of the specified type from an XObject.

See Also


Advanced LINQ to XML Programming

Build Date: