XName.Implicit(String to XName) Operator
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Important
This API is not CLS-compliant.
Converts a string formatted as an expanded XML name (that is,{namespace}localname
) to an XName object.
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
Parameters
- expandedName
- String
A string that contains an expanded XML name in the format {namespace}localname
.
Returns
An XName object constructed from the expanded name.
- Attributes
Examples
The following example creates an XName by assigning a string to it, which invokes this implicit conversion operator.
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
This example produces the following output:
<Root xmlns="http://www.adventure-works.com">content</Root>
<Root xmlns="http://www.adventure-works.com">content</Root>
Remarks
You are using this implicit operator when you create an XElement or XAttribute by passing a string to the appropriate constructor.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기