Click here to Skip to main content
15,897,891 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to SET Geo Location Pin
Gerry Schmitz5-Oct-15 9:33
mveGerry Schmitz5-Oct-15 9:33 
GeneralMessage Removed Pin
5-Oct-15 9:37
professionalN_tro_P5-Oct-15 9:37 
GeneralRe: How to SET Geo Location Pin
Gerry Schmitz5-Oct-15 10:00
mveGerry Schmitz5-Oct-15 10:00 
GeneralMessage Removed Pin
5-Oct-15 11:54
professionalN_tro_P5-Oct-15 11:54 
GeneralRe: How to SET Geo Location Pin
Gerry Schmitz5-Oct-15 12:24
mveGerry Schmitz5-Oct-15 12:24 
Questionrecursive function to print data in the console in the output of a tree structure in c# Pin
darkyMats5-Oct-15 4:13
darkyMats5-Oct-15 4:13 
AnswerRe: recursive function to print data in the console in the output of a tree structure in c# Pin
CHill605-Oct-15 4:20
mveCHill605-Oct-15 4:20 
GeneralRe: recursive function to print data in the console in the output of a tree structure in c# Pin
darkyMats5-Oct-15 4:26
darkyMats5-Oct-15 4:26 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MatsTest
{
    class Program
    {
        static void Main(string[] args)
        {
           
            List<Area> areas = new List<Area>();
            Area area = new Area();
            
            area.ID = 1;
            area.Description = "Continent";
            areas.Add(area);

            Area area2 = new Area();
            area2.ID = 2;
            area2.Description = "Country";
            area2.ParentID = 1;
            areas.Add(area2);

            Area area3 = new Area();
            area3.ID = 3;
            area3.Description = "Province";
            area3.ParentID = 2;
            areas.Add(area3);

            Area area4 = new Area();
            area4.ID = 4;
            area4.Description = "City1";
            area4.ParentID = 3;
            areas.Add(area4);

            Area area5 = new Area();
            area5.ID = 5;
            area5.Description = "Surbub1";
            area5.ParentID = 6;
            areas.Add(area5);

            Area area6 = new Area();
            area6.ID = 6;
            area6.Description = "City2";
            area6.ParentID = 3;
            areas.Add(area6);

            Area area7 = new Area();
            area7.ID = 7;
            area7.Description = "Surbub2";
            area7.ParentID = 6;
            areas.Add(area7);

            Area area8 = new Area();
            area8.ID = 8;
            area8.Description = "Surbub3";
            area8.ParentID = 6;
            areas.Add(area8);

            Area area9 = new Area();
            area9.ID = 9;
            area9.Description = "Surbub4";
            area9.ParentID = 4;
            areas.Add(area9);

            Area area10 = new Area();
            area10.ID = 10;
            area10.Description = "House1";
            area10.ParentID = 7;
            areas.Add(area10);

            Area area11 = new Area();
            area11.ID = 11;
            area11.Description = "House3";
            area11.ParentID = 9;
            areas.Add(area11);

            Area area12 = new Area();
            area12.ID = 12;
            area12.Description = "House4";
            area12.ParentID = 8;
            areas.Add(area12);

            Area area13 = new Area();
            area13.ID = 13;
            area13.Description = "House5";
            area13.ParentID = 8;
            areas.Add(area13);

            Area area14 = new Area();
            area14.ID = 14;
            area14.Description = "House6";
            area14.ParentID = 7;
            areas.Add(area14);

            var parent = areas.FirstOrDefault(s => s.ID.Equals(1));

            var parentids = areas.Select(x => x.ParentID).Distinct().ToList();

            //Console.WriteLine("-" + parent.Description);
            foreach (var i in areas)
            {
                if ( i.ParentID == 0)
                {

                    Console.WriteLine("-" + i.Description);

                    List<Area> children = areas.FindAll(s => s.ParentID.Equals(i.ID)).ToList();
                    foreach (var c in children)
                    {
                        Console.WriteLine("--" + c.Description);

                        List<Area> children2 = areas.FindAll(s => s.ParentID.Equals(c.ID)).ToList();
                        foreach (var c2 in children2)
                        {
                            Console.WriteLine("---" + c2.Description);

                            List<Area> children3 = areas.FindAll(s => s.ParentID.Equals(c2.ID)).ToList();
                            foreach (var c3 in children3)
                            {
                                Console.WriteLine("----" + c3.Description);

                                List<Area> children4 = areas.FindAll(s => s.ParentID.Equals(c3.ID)).ToList();
                                foreach (var c4 in children4)
                                {
                                    Console.WriteLine("-----" + c4.Description);

                                    List<Area> children5 = areas.FindAll(s => s.ParentID.Equals(c4.ID)).ToList();
                                    foreach (var c5 in children5)
                                    {
                                        Console.WriteLine("------" + c5.Description);    
                                    }
                                }
                            }

                        }

                    }                   
                }
            }

            Console.ReadLine();
        }
    }
}

GeneralRe: recursive function to print data in the console in the output of a tree structure in c# Pin
CHill605-Oct-15 4:36
mveCHill605-Oct-15 4:36 
GeneralRe: recursive function to print data in the console in the output of a tree structure in c# Pin
darkyMats5-Oct-15 7:59
darkyMats5-Oct-15 7:59 
GeneralRe: recursive function to print data in the console in the output of a tree structure in c# Pin
CHill605-Oct-15 9:38
mveCHill605-Oct-15 9:38 
GeneralRe: recursive function to print data in the console in the output of a tree structure in c# Pin
darkyMats5-Oct-15 9:41
darkyMats5-Oct-15 9:41 
GeneralRe: recursive function to print data in the console in the output of a tree structure in c# Pin
CHill605-Oct-15 9:53
mveCHill605-Oct-15 9:53 
GeneralRe: recursive function to print data in the console in the output of a tree structure in c# Pin
darkyMats5-Oct-15 10:36
darkyMats5-Oct-15 10:36 
GeneralRe: recursive function to print data in the console in the output of a tree structure in c# Pin
Ravi Bhavnani6-Oct-15 5:13
professionalRavi Bhavnani6-Oct-15 5:13 
GeneralRe: recursive function to print data in the console in the output of a tree structure in c# Pin
OriginalGriff5-Oct-15 4:44
mveOriginalGriff5-Oct-15 4:44 
GeneralRe: recursive function to print data in the console in the output of a tree structure in c# Pin
CHill605-Oct-15 5:58
mveCHill605-Oct-15 5:58 
AnswerRe: recursive function to print data in the console in the output of a tree structure in c# Pin
Gerry Schmitz5-Oct-15 10:52
mveGerry Schmitz5-Oct-15 10:52 
Questionclick serche button webbrouwser c# Pin
altar6664-Oct-15 10:19
altar6664-Oct-15 10:19 
AnswerRe: click serche button webbrouwser c# Pin
F-ES Sitecore4-Oct-15 22:39
professionalF-ES Sitecore4-Oct-15 22:39 
Questionusing toupper to uppercase an array index Pin
doughyi8u4-Oct-15 6:32
doughyi8u4-Oct-15 6:32 
AnswerRe: using toupper to uppercase an array index Pin
OriginalGriff4-Oct-15 6:39
mveOriginalGriff4-Oct-15 6:39 
GeneralRe: using toupper to uppercase an array index Pin
Agent__0074-Oct-15 17:58
professionalAgent__0074-Oct-15 17:58 
AnswerRe: using toupper to uppercase an array index Pin
Gerry Schmitz4-Oct-15 11:32
mveGerry Schmitz4-Oct-15 11:32 
AnswerRe: using toupper to uppercase an array index Pin
PANKAJMAURYA12-Oct-15 20:59
professionalPANKAJMAURYA12-Oct-15 20:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.