XName.NamespaceName 属性

定义

返回此 XNamespaceXName 的 URI。Returns the URI of the XNamespace for this XName.

public:
 property System::String ^ NamespaceName { System::String ^ get(); };
public string NamespaceName { get; }
member this.NamespaceName : string
Public ReadOnly Property NamespaceName As String

属性值

String

XNamespaceXName 的 URI。The URI of the XNamespace for this XName.

示例

此示例在命名空间中创建一个元素,然后打印该元素的命名空间。This example creates an element in a namespace, and then prints the element's namespace.

XNamespace aw = "http://www.adventure-works.com";  
XElement root = new XElement(aw + "Root");  
Console.WriteLine(root.Name.NamespaceName);  
Imports <xmlns="http://www.adventure-works.com">  

Module Module1  
    Sub Main()  
        Dim root As XElement = <Root/>  
        Console.WriteLine(root.Name.NamespaceName)  
    End Sub  
End Module  

该示例产生下面的输出:This example produces the following output:

http://www.adventure-works.com  

注解

这是一个用于从中获取命名空间名称的便利属性 XNameThis is a convenience property to get the namespace name from an XName.

适用于