XText.Value 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定這個節點的值。
public:
property System::String ^ Value { System::String ^ get(); void set(System::String ^ value); };
public string Value { get; set; }
member this.Value : string with get, set
Public Property Value As String
屬性值
String,其中包含這個節點的值。
範例
下列範例顯示取得和設定此屬性。
XElement root = new XElement("Root", "Some text");
XText txtNode = root.Nodes().OfType<XText>().First();
Console.WriteLine(txtNode.Value);
txtNode.Value = "New text";
Console.WriteLine(txtNode.Value);
root.Value = "Newer text";
txtNode = root.Nodes().OfType<XText>().First();
Console.WriteLine(txtNode.Value);
Dim root As XElement = <Root>Some text</Root>
Dim txtNode As XText = root.Nodes().OfType(Of XText).First()
Console.WriteLine(txtNode.Value)
txtNode.Value = "New text"
Console.WriteLine(txtNode.Value)
root.Value = "Newer text"
txtNode = root.Nodes().OfType(Of XText).First()
Console.WriteLine(txtNode.Value)
這個範例會產生下列輸出:
Some text
New text
Newer text
備註
設定此屬性將會引發 Changed 和 Changing 事件。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應