LastChild
Innehåll
[
Dölj
]CompositeNode.LastChild property
Hämtar nodens sista barn.
public Node LastChild { get; }
Anmärkningar
Om det inte finns någon sista underordnad nod, ennull
returneras.
Exempel
Visar hur man använder metoderna Node och CompositeNode för att ta bort ett avsnitt före det sista avsnittet i dokumentet.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Section 1 text.");
builder.InsertBreak(BreakType.SectionBreakContinuous);
builder.Writeln("Section 2 text.");
// Båda sektionerna är syskon till varandra.
Section lastSection = (Section)doc.LastChild;
Section firstSection = (Section)lastSection.PreviousSibling;
// Ta bort en sektion baserat på dess syskonrelation med en annan sektion.
if (lastSection.PreviousSibling != null)
doc.RemoveChild(firstSection);
// Avsnittet vi tog bort var det första, vilket lämnade dokumentet med bara det andra.
Assert.AreEqual("Section 2 text.", doc.GetText().Trim());
Se även
- class Node
- class CompositeNode
- namnutrymme Aspose.Words
- hopsättning Aspose.Words