0

I would like to store and process information which I have in following format.

Please let me know what are the suitable data types available in C# to achieve this requirement.

Also "stat" is additional information which I would like to attach with each node. How should I carry that with each node.

Root -stat
       |
       !_Node1 - stat
       |         |_Node1-1  stat
       |       
       |_Node2 -stat
         |_Node2-1 - stat
Alberto De Caro
  • 5,147
  • 9
  • 47
  • 73
user987316
  • 894
  • 4
  • 13
  • 35

2 Answers2

2

What about this?

public class Node
{
    public string Stat;
    public List<Node> Children;
}
L.B
  • 114,136
  • 19
  • 178
  • 224
0

Your data structure is a composite patern :

Component :

  • is the abstraction for all components, including composite ones declares the interface for objects in the composition
  • (optional) defines an interface for accessing a component's parent in the recursive structure, and implements it if that's appropriate

Leaf :

  • represents leaf objects in the composition .
  • implements all Component methods

Composite :

  • represents a composite Component (component having children)
  • implements methods to manipulate children
  • implements all Component methods, generally by delegating them to its children

enter image description here

Nicolas Voron
  • 2,916
  • 1
  • 21
  • 35