XAttribute.SetValue(Object) Método
Definición
Establece el valor de este atributo.Sets the value of this attribute.
public:
void SetValue(System::Object ^ value);
public void SetValue (object value);
member this.SetValue : obj -> unit
Public Sub SetValue (value As Object)
Parámetros
- value
- Object
El valor que se va a asignar a este atributo.The value to assign to this attribute.
Excepciones
El parámetro value
es null
.The value
parameter is null
.
Ejemplos
En el ejemplo siguiente se crea un elemento con varios atributos.The following example creates an element with several attributes. A continuación, cambia el contenido de uno de los atributos.It then changes the contents of one of the attributes.
XElement root = new XElement("Root",
new XAttribute("Att1", "content1"),
new XAttribute("Att2", "content2"),
new XAttribute("Att3", "content3")
);
XAttribute att = root.Attribute("Att2");
att.SetValue("new content");
Console.WriteLine(root);
Dim root As XElement = <Root Att1="content1" Att2="content2" Att3="content3"/>
Dim att As XAttribute = root.Attribute("Att2")
att.SetValue("new content")
Console.WriteLine(root)
Este ejemplo produce el siguiente resultado:This example produces the following output:
<Root Att1="content1" Att2="new content" Att3="content3" />
Comentarios
Se convierte el valor en su representación de cadena y se asigna a la propiedad Value.The value is converted to its string representation and assigned to the Value property.
No es válido pasar una instancia de una clase que deriva de, como XObject XElement o XAttribute .It is invalid to pass an instance of a class that derives from XObject, such as XElement or XAttribute.
Este método generará los Changed eventos y Changing .This method will raise the Changed and the Changing events.