I have an issue creating a treee from a list of list of string. Here my input data :
IReadOnlyList<IReadOnlyList<string>> listeDesParcours = new List<IReadOnlyList<string>>
{
new List<string>
{
"Produit","Sinistre","Particulier","Auto","RC"
},
new List<string>
{
"Produit","Sinistre","Entreprise","Auto","2roues"
},
new List<string>
{
"Produit","reclamation","Particulier","Moto","PP"
},
new List<string>
{
"Produit","reclamation","Entreprise","Auto","TT"
},
new List<string>
{
"Produit","reclamation","Entreprise","Auto","PP"
},
new List<string>
{
"Produit","souscription","Salarie","Aviation"
},
new List<string>
{
"Produit","souscription","Salarie","Aviation","Airbus"
},
new List<string>
{
"Produit","reclamation","Reclamation tout court"
},
new List<string>
{
"Produit","Produit tout court"
},
new List<string>
{
"Produit","Sinistre","Entreprise","Auto","5roues"
}
};
As you can see, its a list of list of string and i want to get a tree from it . here is my object that i want to return in the end
public class Node
{
public string Value { get; set; }
public List<Node> Childs { get; set; }
}
and this is how i want to get the structure
RootElement
|
___________________________Produit__________________________
/ | \
__sinistre___________ reclamation_______ Souscription
| \ / \ |
entreprise particulier entreprise particulier Salarie______________
| | | | | \
auto auto auto auto Marine Aviation__
/ \
Airbus Boing
Can anyone point me please to a recursive method that allows me to fill the tree from the list of list please?
Thanks in advance
EDIT : After the last comment i want to clarify that i want to get the object of type Node that i created ... however my Input is the list of list of string