XName.Implicit(String to XName) Opérateur

Définition

Important

Cette API n’est pas conforme CLS.

Convertit une chaîne mise en forme en tant que nom XML développé (c’est-à-dire,{namespace}localname ) en objet XName .

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

Paramètres

expandedName
String

Chaîne qui contient un nom XML développé au format {namespace}localname.

Retours

Objet XName construit à partir du nom développé.

Attributs

Exemples

L’exemple suivant crée un en XName lui affectant une chaîne, qui appelle cet opérateur de conversion implicite.

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

Cet exemple produit la sortie suivante :

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

Remarques

Vous utilisez cet opérateur implicite lorsque vous créez un XElement ou XAttribute en passant une chaîne au constructeur approprié.

S’applique à

Voir aussi