Click here to Skip to main content
11,409,854 members (54,368 online)
Click here to Skip to main content
Articles » Languages » C# » Generics » Downloads
Add your own
alternative version

Simple Generic Tree

, 6 Sep 2012 CPOL
Simple Generic Tree in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NodeTree;

namespace TestConsole
    class Program
        static void Main(string[] args)
            SpecialTreeNode rootTreeNode = new SpecialTreeNode("Node1");
            var node2a = new SpecialTreeNode("Node 2a");
            var node2b = new SpecialTreeNode("Node 2b");
            var node2c = new SpecialTreeNode("Node 2c");

            node2a.IsSpecial = true;
            node2c.IsSpecial = true;


            var node3ca = new SpecialTreeNode("Node 3ca");

            Console.WriteLine(string.Format("Root has {0} nodes", rootTreeNode.ChildNodes.Count));
            Console.WriteLine(string.Format("Root has {0} special nodes", rootTreeNode.GetSpecialNodes().Count));
            Console.WriteLine(string.Format("Root has {0} special leaf nodes", rootTreeNode.GetSpecialLeafNodes().Count));
            Console.WriteLine(string.Format("Root has {0} leaf nodes", rootTreeNode.GetLeafNodes().Count));

            Console.WriteLine("Press any key to end");

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.


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


About the Author


United Kingdom United Kingdom
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150414.5 | Last Updated 6 Sep 2012
Article Copyright 2012 by alc_aardvark
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid