Condividi tramite


XText.Value Proprietà

Definizione

Ottiene o imposta il valore di questo nodo.

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

Valore della proprietà

String che contiene il valore di questo nodo.

Esempio

Nell'esempio seguente viene illustrato come ottenere e impostare questa proprietà.

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)

Nell'esempio viene prodotto l'output seguente:

Some text
New text
Newer text

Commenti

L'impostazione Changing di questa proprietà genererà gli Changed eventi e .

Si applica a

Vedi anche