XAttribute.ToString Method
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.
Converts the current XAttribute object to a string representation.
public:
override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
Returns
A String containing the XML text representation of an attribute and its value.
Examples
The following example creates an element with several attributes. It then gets an attribute and displays it and its content by calling this method.
XElement root = new XElement("Root",
new XAttribute("Att1", "content1"),
new XAttribute("Att2", "content2"),
new XAttribute("Att3", "content3")
);
XAttribute att = root.Attribute("Att2");
Console.WriteLine(att.ToString());
Dim root As XElement = <Root Att1="content1" Att2="content2" Att3="content3"/>
Dim att As XAttribute = root.Attribute("Att2")
Console.WriteLine(att.ToString())
This example produces the following output:
Att2="content2"
Remarks
This method returns a string in the form of AttributeName="content"
.
Warning
When this method is called and XAttribute contains control character, an exception is thrown with a message like: hexadecimal value 0x0B, is an invalid character.
Applies to
See also
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om