XStreamingElement.ToString Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Devuelve el XML de este elemento de streaming, deshabilitando opcionalmente el formato.
Sobrecargas
| Nombre | Description |
|---|---|
| ToString() |
Devuelve el XML con formato (con sangría) de este elemento de streaming. |
| ToString(SaveOptions) |
Devuelve el XML de este elemento de streaming, deshabilitando opcionalmente el formato. |
Comentarios
Tenga en cuenta que al depurar un programa que usa XStreamingElement, mostrar el valor de un objeto hace que se llame a su ToString método. Esto hace que el XML se serialice. Si la semántica de la consulta de elementos de streaming es tal que el elemento de streaming solo se puede transmitir una vez, esto puede provocar un comportamiento no deseado en la experiencia de depuración.
ToString()
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
Devuelve el XML con formato (con sangría) de este elemento de streaming.
public:
override System::String ^ ToString();
public override string ToString();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
Devoluciones
que String contiene el XML con sangría.
Ejemplos
En el ejemplo siguiente se muestran dos usos de ToString. El primer uso conserva el espacio en blanco. La segunda serializa con XStreamingElement formato.
XElement srcTree = new XElement("Root",
new XElement("Child", 1),
new XElement("Child", 2),
new XElement("Child", 3),
new XElement("Child", 4),
new XElement("Child", 5)
);
XStreamingElement dstTree = new XStreamingElement("NewRoot",
from el in srcTree.Elements()
where (int)el == 3
select new XElement("DifferentChild", (int)el)
);
Console.WriteLine(dstTree.ToString(SaveOptions.DisableFormatting));
Console.WriteLine("------");
Console.WriteLine(dstTree.ToString());
Dim srcTree As XElement = _
<Root>
<Child>1</Child>
<Child>2</Child>
<Child>3</Child>
<Child>4</Child>
<Child>5</Child>
</Root>
Dim dstTree As XStreamingElement = New XStreamingElement("NewRoot", _
From el In srcTree.Elements() _
Where el.Value = 3 _
Select <DifferentChild><%= el.Value %></DifferentChild> _
)
Console.WriteLine(dstTree.ToString(SaveOptions.DisableFormatting))
Console.WriteLine("------")
Console.WriteLine(dstTree.ToString())
Este ejemplo produce el siguiente resultado:
<NewRoot><DifferentChild>3</DifferentChild></NewRoot>
------
<NewRoot>
<DifferentChild>3</DifferentChild>
</NewRoot>
Comentarios
Tenga en cuenta que al depurar un programa que usa XStreamingElement, mostrar el valor de un objeto hace que se llame a su ToString método. Esto hace que el XML se serialice. Si la semántica de la consulta de elementos de streaming es tal que el elemento de streaming solo se puede transmitir una vez, esto puede provocar un comportamiento no deseado en la experiencia de depuración.
Consulte también
Se aplica a
ToString(SaveOptions)
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
Devuelve el XML de este elemento de streaming, deshabilitando opcionalmente el formato.
public:
System::String ^ ToString(System::Xml::Linq::SaveOptions options);
public string ToString(System.Xml.Linq.SaveOptions options);
override this.ToString : System.Xml.Linq.SaveOptions -> string
Public Function ToString (options As SaveOptions) As String
Parámetros
- options
- SaveOptions
que SaveOptions especifica el comportamiento de formato.
Devoluciones
que String contiene el XML.
Ejemplos
En el ejemplo siguiente se muestran dos usos de ToString. El primer uso conserva el espacio en blanco. La segunda serializa con XStreamingElement formato.
XElement srcTree = new XElement("Root",
new XElement("Child", 1),
new XElement("Child", 2),
new XElement("Child", 3),
new XElement("Child", 4),
new XElement("Child", 5)
);
XStreamingElement dstTree = new XStreamingElement("NewRoot",
from el in srcTree.Elements()
where (int)el == 3
select new XElement("DifferentChild", (int)el)
);
Console.WriteLine(dstTree.ToString(SaveOptions.DisableFormatting));
Console.WriteLine("------");
Console.WriteLine(dstTree.ToString());
Dim srcTree As XElement = _
<Root>
<Child>1</Child>
<Child>2</Child>
<Child>3</Child>
<Child>4</Child>
<Child>5</Child>
</Root>
Dim dstTree As XStreamingElement = New XStreamingElement("NewRoot", _
From el In srcTree.Elements() _
Where el.Value = 3 _
Select <DifferentChild><%= el.Value %></DifferentChild> _
)
Console.WriteLine(dstTree.ToString(SaveOptions.DisableFormatting))
Console.WriteLine("------")
Console.WriteLine(dstTree.ToString())
Este ejemplo produce el siguiente resultado:
<NewRoot><DifferentChild>3</DifferentChild></NewRoot>
------
<NewRoot>
<DifferentChild>3</DifferentChild>
</NewRoot>
Comentarios
Tenga en cuenta que al depurar un programa que usa XStreamingElement, mostrar el valor de un objeto hace que se llame a su ToString método. Esto hace que el XML se serialice. Si la semántica de la consulta de elementos de streaming es tal que el elemento de streaming solo se puede transmitir una vez, esto puede provocar un comportamiento no deseado en la experiencia de depuración.