-1

I am doing it since last many days but I am not sure how can i build my logic for this in c#. I have to build logic something like this.

For example

The scenario is A has two childs B and C. Now B has no child and C has childs records of D,E,F . same way it can be at any depth. but lets for now we are considering this case. Now I am starting from A and want to find all the descendant elements of A. so the result should be B,C,D,E,F.

but I am not sure how can i build my logic till n hierarchy. can anybody please suggest. I am planning to start my logic like this

Find all the childs of A
Now For Looop
 ........
Kartik Patel
  • 9,303
  • 12
  • 33
  • 53

1 Answers1

0

you can sort this out with a simple recursive function.

here is the logic you want. I am not writing the while C# code would be happy to help any questions.

parent send as param 
Find all the childs of parent
Now For Looop
  check parent has child then write it and call this method again whit parent.child
end loop

in the main of your code call the method with A
Onur Topal
  • 3,042
  • 1
  • 24
  • 41