XName.ToString Method

Definition

Returns the expanded XML name in the format {namespace}localname.

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

Returns

A String that contains the expanded XML name in the format {namespace}localname.

Examples

The following example calls WriteLine, passing an XName. This causes the ToString method to be called.

XNamespace ns = "http://www.adventure-works.com";  
XElement root = new XElement(ns + "Root", "content");  
Console.WriteLine(root.Name);  
Console.WriteLine(root.Name.LocalName);  
Console.WriteLine(root.Name.Namespace);  
Imports <xmlns="http://www.adventure-works.com">  
  
Module Module1  
    Sub Main()  
        Dim root As XElement = <Root>content</Root>  
        Console.WriteLine(root.Name)  
        Console.WriteLine(root.Name.LocalName)  
        Console.WriteLine(root.Name.Namespace)  
    End Sub  
End Module  

This example produces the following output:

{http://www.adventure-works.com}Root  
Root  
http://www.adventure-works.com  

Applies to

See also