XAttribute.ToString メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
現在の XAttribute オブジェクトを文字列形式に変換します。
public:
override System::String ^ ToString();
public override string ToString();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
返品
属性とその値の XML テキスト表現を含む String 。
例
次の例では、複数の属性を持つ要素を作成します。 次に、属性を取得し、このメソッドを呼び出して属性とその内容を表示します。
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())
この例を実行すると、次の出力が生成されます。
Att2="content2"
注釈
このメソッドは、 AttributeName="content"の形式で文字列を返します。
Warning
このメソッドが呼び出され、 XAttribute に制御文字が含まれている場合、16 進数の値0x0Bのようなメッセージで例外がスローされます。無効な文字です。