XName.Implicit(String to XName) Operatore

Definizione

Importante

Questa API non è conforme a CLS.

Converte una stringa formattata come nome XML espanso (ovvero,{namespace}localname ) in un XName oggetto.

public:
 static operator System::Xml::Linq::XName ^(System::String ^ expandedName);
[System.CLSCompliant(false)]
public static implicit operator System.Xml.Linq.XName (string expandedName);
[System.CLSCompliant(false)]
public static implicit operator System.Xml.Linq.XName? (string? expandedName);
[<System.CLSCompliant(false)>]
static member op_Implicit : string -> System.Xml.Linq.XName
Public Shared Widening Operator CType (expandedName As String) As XName

Parametri

expandedName
String

Stringa contenente un nome XML espanso nel formato {namespace}localname.

Restituisce

Oggetto XName costruito da un nome esteso.

Attributi

Esempio

Nell'esempio seguente viene creato un oggetto XName assegnando una stringa a essa, che richiama questo operatore di conversione implicito.

XElement el = new XElement("{http://www.adventure-works.com}Root", "content");
Console.WriteLine(el);

// The preferred approach is to initialize an XNamespace object
// and use the overload of the addition operator.
XNamespace aw = "http://www.adventure-works.com";
XElement root = new XElement(aw + "Root", "content");
Console.WriteLine(root);
Imports <xmlns="http://www.adventure-works.com">

Module Module1
    Sub Main()
        Dim el As XElement = New XElement("{http://www.adventure-works.com}Root", "content")
        Console.WriteLine(el)

        ' The preferred approach is to import a global namespace and
        ' use an XML literal.
        Dim root As XElement = <Root>content</Root>
        Console.WriteLine(root)
    End Sub
End Module

Nell'esempio viene prodotto l'output seguente:

<Root xmlns="http://www.adventure-works.com">content</Root>
<Root xmlns="http://www.adventure-works.com">content</Root>

Commenti

Questo operatore implicito viene usato quando si crea o passando una XElementXAttribute stringa al costruttore appropriato.

Si applica a

Vedi anche