AncestorsAndSelf
The AncestorsAndSelf operator can be called on a sequence of elements and returns a sequence containing the ancestor elements of each source element and the source element itself. This operator is just like the Ancestors operator except for the fact that it can only be called on elements, as opposed to nodes, and also includes each source element in the returned sequence of ancestor elements.
Prototypes
The AncestorsAndSelf operator has two prototypes.
Example. The First AncestorsAndSelf Prototype
public static IEnumerable<XElement> AncestorsAndSelf ( this IEnumerable<XElement> source ) |
This version of the operator can be called on a sequence of elements and returns a sequence of elements containing each source element itself ...
Get Pro LINQ: Language Integrated Query in C# 2008 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.