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不能通过将注释的内容强制转换为字符串来检索注释的内容。 相反,必须使用此属性来检索内容。

设置此属性将引发 Changed 事件和 Changing 事件。

适用于

另请参阅