XmlEnumAttribute.Name Property

 

Gets or sets the value generated in an XML-document instance when the XmlSerializer serializes an enumeration, or the value recognized when it deserializes the enumeration member.

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

public string Name { get; set; }

Property Value

Type: System.String

The value generated in an XML-document instance when the XmlSerializer serializes the enumeration, or the value recognized when it is deserializes the enumeration member.

Specify the Name when you want the generated XML data to differ from the enumeration identifier.

System_CAPS_noteNote

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

The following example applies the XmlEnumAttribute attribute to members of an enumeration. The generated XML data conforms to the values set for the Name property.

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: