Click here to Skip to main content
15,891,409 members
Articles / Programming Languages / C#

Apply "yield return" recursively - iterating tree data structures

Rate me:
Please Sign up or sign in to vote.
4.29/5 (16 votes)
21 Feb 2008CPOL2 min read 52.9K   179   27  
A generic function that enables "deep-iterating" the leafs of arbitrary tree data structures simply using foreach.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Allgemeine Informationen �ber eine Assembly werden �ber die folgenden 
// Attribute gesteuert. �ndern Sie diese Attributwerte, um die Informationen zu �ndern,
// die mit einer Assembly verkn�pft sind.
[assembly: AssemblyTitle("TreeIterations")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Cosa Nostra")]
[assembly: AssemblyProduct("TreeIterations")]
[assembly: AssemblyCopyright("Copyright � Cosa Nostra 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 
// f�r COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 
// COM zugreifen m�ssen, legen Sie das ComVisible-Attribut f�r diesen Typ auf "true" fest.
[assembly: ComVisible(false)]

// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt f�r COM verf�gbar gemacht wird
[assembly: Guid("5a09b0f4-6cf0-4ee6-a5a5-dfbd0d9caaf3")]

// Versionsinformationen f�r eine Assembly bestehen aus den folgenden vier Werten:
//
//      Hauptversion
//      Nebenversion 
//      Buildnummer
//      Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions