Implicit Conversion (String to XName)
Collapse the table of content
Expand the table of content

XName Widening Conversion (String to XName)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Converts a string formatted as an expanded XML name (that is,{namespace}localname) to an XName object.

This API is not CLS-compliant. 

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

'Declaration
Public Shared Widening Operator CType ( _
	expandedName As String _
) As XName

Parameters

expandedName
Type: System.String
A string that contains an expanded XML name in the format {namespace}localname.

Return Value

Type: System.Xml.Linq.XName
An XName object constructed from the expanded name.

You are using this implicit operator when you create an XElement or XAttribute by passing a string to the appropriate constructor.

The following example creates an XName by assigning a string to it, which invokes this implicit conversion operator.


'add the following line to the the Imports section:
'Imports <xmlns="http://www.adventure-works.com">
Dim output As New StringBuilder
Dim el As XElement = New XElement("{http://www.adventure-works.com}Root", "content")
output.Append(el)
output.Append(Environment.NewLine)

' The preferred approach is to import a global namespace and 
' use an XML literal.
Dim root As XElement = <Root>content</Root>
output.Append(root)
output.Append(Environment.NewLine)

OutputTextBlock.Text = output.ToString()


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft