XStreamingElement.Add Metodo
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Aggiunge il contenuto specificato come figlio a XStreamingElement.
Add(Object) |
Aggiunge il contenuto specificato come figlio a XStreamingElement. |
Add(Object[]) |
Aggiunge il contenuto specificato come figlio a XStreamingElement. |
- Origine:
- XStreamingElement.cs
- Origine:
- XStreamingElement.cs
- Origine:
- XStreamingElement.cs
Aggiunge il contenuto specificato come figlio a XStreamingElement.
public:
void Add(System::Object ^ content);
public void Add(object content);
public void Add(object? content);
member this.Add : obj -> unit
Public Sub Add (content As Object)
Parametri
- content
- Object
Contenuto da aggiungere all'elemento di flusso.
Esempio
Nell'esempio seguente viene creato un nuovo XStreamingElementoggetto . Aggiunge quindi due query all'elemento di streaming. Le query non vengono iterazione finché l'elemento di streaming non viene serializzato.
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");
dstTree.Add(
from el in srcTree.Elements()
where (int)el <= 1
select new XElement("Child", (int)el)
);
dstTree.Add(
from el in srcTree.Elements()
where (int)el >= 3
select new XElement("DifferentChild", (int)el)
);
Console.WriteLine(dstTree);
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")
dstTree.Add( _
From el In srcTree.Elements() _
Where el.Value <= 1 _
Select <Child><%= el.Value %></Child> _
)
dstTree.Add( _
From el In srcTree.Elements() _
Where el.Value >= 3 _
Select <DifferentChild><%= el.Value %></DifferentChild> _
)
Console.WriteLine(dstTree)
Nell'esempio viene prodotto l'output seguente:
<NewRoot>
<Child>1</Child>
<DifferentChild>3</DifferentChild>
<DifferentChild>4</DifferentChild>
<DifferentChild>5</DifferentChild>
</NewRoot>
Commenti
Questo costruttore aggiunge il contenuto e gli attributi specificati all'oggetto XStreamingElement. Anche se spesso è possibile costruire l'oggetto in una singola istruzione, a volte è più pratico aggiungere contenuto all'elemento XStreamingElement di streaming in modo incrementale.
Le query non vengono iterazione fino a quando non XStreamingElement viene serializzata. In contrasto con l'uso di query per il contenuto di un XElementoggetto , in cui le query vengono iterate al momento della costruzione del nuovo XElementoggetto .
Per informazioni dettagliate sul contenuto valido che può essere passato a questa funzione, vedere Contenuto valido degli oggetti XElement e XDocument.
Vedi anche
Si applica a
.NET 10 e altre versioni
Prodotto | Versioni |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
- Origine:
- XStreamingElement.cs
- Origine:
- XStreamingElement.cs
- Origine:
- XStreamingElement.cs
Aggiunge il contenuto specificato come figlio a XStreamingElement.
public:
void Add(... cli::array <System::Object ^> ^ content);
public void Add(params object[] content);
public void Add(params object?[] content);
member this.Add : obj[] -> unit
Public Sub Add (ParamArray content As Object())
Parametri
- content
- Object[]
Contenuto da aggiungere all'elemento di flusso.
Esempio
Nell'esempio seguente viene creato un nuovo XStreamingElementoggetto . Aggiunge quindi due query all'elemento di streaming. Le query non vengono iterazione finché l'elemento di streaming non viene serializzato.
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");
dstTree.Add(
from el in srcTree.Elements()
where (int)el <= 1
select new XElement("Child", (int)el)
);
dstTree.Add(
from el in srcTree.Elements()
where (int)el >= 3
select new XElement("DifferentChild", (int)el)
);
Console.WriteLine(dstTree);
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")
dstTree.Add( _
From el In srcTree.Elements() _
Where el.Value <= 1 _
Select <Child><%= el.Value %></Child> _
)
dstTree.Add( _
From el In srcTree.Elements() _
Where el.Value >= 3 _
Select <DifferentChild><%= el.Value %></DifferentChild> _
)
Console.WriteLine(dstTree)
Nell'esempio viene prodotto l'output seguente:
<NewRoot>
<Child>1</Child>
<DifferentChild>3</DifferentChild>
<DifferentChild>4</DifferentChild>
<DifferentChild>5</DifferentChild>
</NewRoot>
Commenti
Questo costruttore aggiunge il contenuto e gli attributi specificati all'oggetto XStreamingElement. Anche se spesso è possibile costruire l'oggetto in una singola istruzione, a volte è più pratico aggiungere contenuto all'elemento XStreamingElement di streaming in modo incrementale.
Le query non vengono iterazione fino a quando non XStreamingElement viene serializzata. In contrasto con l'uso di query per il contenuto di un XElementoggetto , in cui le query vengono iterate al momento della costruzione del nuovo XElementoggetto .
Per informazioni dettagliate sul contenuto valido che può essere passato a questa funzione, vedere Contenuto valido degli oggetti XElement e XDocument.
Vedi anche
Si applica a
.NET 10 e altre versioni
Prodotto | Versioni |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
Feedback su .NET
.NET è un progetto open source. Seleziona un collegamento per fornire feedback: