XComment.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 A 包含這則註解的字串值。
例外狀況
value 是 null。
範例
以下範例建立一個註解節點。 接著它會擷取註解節點的內容。
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
備註
與 和 XElement不同XAttribute,你無法透過將註解投射成字串來取得其內容。 相反地,你必須利用這個屬性來取得內容。