XStreamingElement.ToString Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Zwraca kod XML dla tego elementu przesyłania strumieniowego, opcjonalnie wyłączając formatowanie.
Przeciążenia
| Nazwa | Opis |
|---|---|
| ToString() |
Zwraca sformatowany (wcięcie) kod XML dla tego elementu przesyłania strumieniowego. |
| ToString(SaveOptions) |
Zwraca kod XML dla tego elementu przesyłania strumieniowego, opcjonalnie wyłączając formatowanie. |
Uwagi
Należy pamiętać, że podczas debugowania programu używającego XStreamingElementmetody , wyświetlanie wartości obiektu powoduje wywołanie jego ToString metody. Powoduje to serializację kodu XML. Jeśli semantyka zapytania elementu przesyłania strumieniowego jest taka, że element przesyłania strumieniowego może być przesyłany strumieniowo tylko raz, może to spowodować niepożądane zachowanie w środowisku debugowania.
ToString()
- Źródło:
- XStreamingElement.cs
- Źródło:
- XStreamingElement.cs
- Źródło:
- XStreamingElement.cs
- Źródło:
- XStreamingElement.cs
- Źródło:
- XStreamingElement.cs
Zwraca sformatowany (wcięcie) kod XML dla tego elementu przesyłania strumieniowego.
public:
override System::String ^ ToString();
public override string ToString();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
Zwraca
Element String zawierający wcięty kod XML.
Przykłady
W poniższym przykładzie pokazano dwa zastosowania .ToString Pierwsze użycie zachowuje biały znak. Drugi serializuje element XStreamingElement z formatowaniem.
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())
Ten przykład generuje następujące wyniki:
<NewRoot><DifferentChild>3</DifferentChild></NewRoot>
------
<NewRoot>
<DifferentChild>3</DifferentChild>
</NewRoot>
Uwagi
Należy pamiętać, że podczas debugowania programu używającego XStreamingElementmetody , wyświetlanie wartości obiektu powoduje wywołanie jego ToString metody. Powoduje to serializację kodu XML. Jeśli semantyka zapytania elementu przesyłania strumieniowego jest taka, że element przesyłania strumieniowego może być przesyłany strumieniowo tylko raz, może to spowodować niepożądane zachowanie w środowisku debugowania.
Zobacz też
Dotyczy
ToString(SaveOptions)
- Źródło:
- XStreamingElement.cs
- Źródło:
- XStreamingElement.cs
- Źródło:
- XStreamingElement.cs
- Źródło:
- XStreamingElement.cs
- Źródło:
- XStreamingElement.cs
Zwraca kod XML dla tego elementu przesyłania strumieniowego, opcjonalnie wyłączając formatowanie.
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
Parametry
- options
- SaveOptions
Element SaveOptions określający zachowanie formatowania.
Zwraca
Element String zawierający kod XML.
Przykłady
W poniższym przykładzie pokazano dwa zastosowania .ToString Pierwsze użycie zachowuje biały znak. Drugi serializuje element XStreamingElement z formatowaniem.
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())
Ten przykład generuje następujące wyniki:
<NewRoot><DifferentChild>3</DifferentChild></NewRoot>
------
<NewRoot>
<DifferentChild>3</DifferentChild>
</NewRoot>
Uwagi
Należy pamiętać, że podczas debugowania programu używającego XStreamingElementmetody , wyświetlanie wartości obiektu powoduje wywołanie jego ToString metody. Powoduje to serializację kodu XML. Jeśli semantyka zapytania elementu przesyłania strumieniowego jest taka, że element przesyłania strumieniowego może być przesyłany strumieniowo tylko raz, może to spowodować niepożądane zachowanie w środowisku debugowania.