O'Reilly logo

Pro LINQ: Language Integrated Query in C# 2008 by Joseph C. Rattz Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required