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

Ancestors

The Ancestors operator can be called on a sequence of nodes and returns a sequence containing the ancestor elements of each source node.

Prototypes

The Ancestors operator has two prototypes.

Example. The First Ancestors Prototype
public static IEnumerable<XElement> Ancestors<T> (
  this IEnumerable<T> source
) where T : XNode

This version of the operator can be called on a sequence of nodes, or objects derived from XNode. It returns a sequence of elements containing the ancestor elements of each node in the source sequence.

Example. The Second Ancestors Prototype
public static IEnumerable<XElement> Ancestors<T> (
  this IEnumerable<T> source,
  XName name
) where T : XNode

This version is like the first, except a name is passed and only ...

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