XComment.Value 屬性

定義

取得或設定這個註解的字串值。

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

例外狀況

valuenull

範例

下列範例會建立批註節點。 然後,它會擷取批註節點的內容。

XComment com = new XComment("This is a comment");  
Console.WriteLine(com.Value);  
Dim com As XComment = New XComment("This is a comment")  
Console.WriteLine(com.Value)  

這個範例會產生下列輸出:

This is a comment  

備註

不同于 XElementXAttribute ,您無法藉由將批註內容轉換成字串來擷取批註的內容。 相反地,您必須使用這個屬性來擷取內容。

設定這個屬性將會引發 ChangedChanging 事件。

適用於

另請參閱