XmlEnumAttribute Constructor (String)

 

Initializes a new instance of the XmlEnumAttribute class, and specifies the XML value that the XmlSerializer generates or recognizes (when it serializes or deserializes the enumeration, respectively).

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

public XmlEnumAttribute(
	string name
)

Parameters

name
Type: System.String

The overriding name of the enumeration member.

System_CAPS_noteNote

You can use the word XmlEnum in your code instead of the longer XmlEnumAttribute.

The following example applies the XmlEnumAttribute to the members of an enumeration. When the XmlSerializer generates XML data for this enumeration, the data conforms to the values of the Name properties.

public enum EmployeeStatus
{
   [XmlEnum("Single")]
   One,
   [XmlEnum("Double")]
   Two,
   [XmlEnum("Triple")]
   Three
}

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: