Edit

Share via


XComment.Value Property

Definition

Gets or sets the string value of this comment.

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

Property Value

A String that contains the string value of this comment.

Exceptions

The value is null.

Examples

The following example creates a comment node. It then retrieves the contents of the comment node.

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 example produces the following output:

This is a comment  

Remarks

Unlike XElement and XAttribute, you cannot retrieve the contents of a comment by casting it to a string. Instead, you must use this property to retrieve the contents.

Setting this property will raise the Changed and the Changing events.

Applies to

See also