Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XNamespace::Addition Operator (XNamespace^, String^)

 
equivalentCodeEntity

Combines an XNamespace object with a local name to create an XName.

Namespace:   System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)

public:
static XName^ operator +(
	XNamespace^ ns,
	String^ localName
)

Parameters

ns
Type: System.Xml.Linq::XNamespace^

An XNamespace that contains the namespace.

localName
Type: System::String^

A String that contains the local name.

Return Value

Type: System.Xml.Linq::XName^

The new XName constructed from the namespace and local name.

This operator enables the common idiom of combining a namespace and a local name in the construction of an element or attribute. This idiom provides some of the benefits of having namespace prefixes, in that you can refer to a namespace using a variable that is short. This eliminates syntactic noise in the code that creates XML trees.

The following example shows the use of the + operator to create an XName from an XNamespace and a local name.

No code example is currently available or this language may not be supported.

In Visual Basic, this is the preferred idiom:


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

Module Module1
    Sub Main()
        Dim aw As XNamespace = GetXmlNamespace()
        Dim root As XElement = _
            <Root>
                <Child/>
            </Root>
        Console.WriteLine(root)
    End Sub
End Module

This example produces the following output:

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

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2017 Microsoft