Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XDeclaration Class


Represents an XML declaration.

Namespace:   System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)


public class XDeclaration

System_CAPS_pubmethodXDeclaration(String, String, String)

Initializes a new instance of the XDeclaration class with the specified version, encoding, and standalone status.


Initializes a new instance of the XDeclaration class from another XDeclaration object.


Gets or sets the encoding for this document.


Gets or sets the standalone property for this document.


Gets or sets the version property for this document.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Provides the declaration as a formatted string.(Overrides Object.ToString().)

An XML declaration is used to declare the XML version, the encoding, and whether or not the XML document is standalone. This class represents the XML concept of an XML declaration.

Just as in the XML standard, declarations are associated with a document. When you create a document, you have the option to specify the declaration for the document. The XDocument class contains the Declaration property, which allows you to set or get the declaration. For information about how to serialize an XML tree with an XML declaration, see Serializing with an XML Declaration.

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2017 Microsoft