XmlElementAttribute.ElementName Vlastnost

Definice

Získá nebo nastaví název vygenerovaného elementu XML.

public:
 property System::String ^ ElementName { System::String ^ get(); void set(System::String ^ value); };
public string ElementName { get; set; }
member this.ElementName : string with get, set
Public Property ElementName As String

Hodnota vlastnosti

String

Název vygenerovaného elementu XML. Výchozí hodnota je identifikátor člena.

Příklady

Následující příklad nastaví ElementName vlastnost hodnoty XmlElementAttribute na novou hodnotu.

// This is the class that will be serialized.
public ref class XClass
{
public:
   /* The XML element name will be XName
   instead of the default ClassName. */
   [XmlElement(ElementName="XName")]
   String^ ClassName;
};
// This is the class that will be serialized.
public class XClass
{
   /* The XML element name will be XName
   instead of the default ClassName. */
   [XmlElement(ElementName = "XName")]
   public string ClassName;
}
' This is the class that will be serialized.
Public Class XClass
   ' The XML element name will be XName
   ' instead of the default ClassName.
   <XmlElement(ElementName := "XName")> Public ClassName() As String
End Class

Poznámky

ElementName Zadejte, jestli se má název vygenerovaného elementu XML lišit od identifikátoru člena.

Stejnou ElementName hodnotu můžete nastavit na více než jeden člen třídy, pokud vygenerovaný dokument XML používá obory názvů XML k rozlišení mezi identicky pojmenovanými členy. Podrobnosti o tom, jak používat obory názvů a názvy předpon v dokumentu XML, najdete v XmlSerializerNamespaces této třídě.

Platí pro

Viz také