How to copy values from nested list into new list

I have a nested list that contains

public class Person
{
    public Person(string name)
    {
        this.Name = name;
    }
public string Name { get; set; }

public List<Person> Childs { get; set; }

}

The list can be used like:

var Persons = new List<Person>();
Persons.Add(new Person(“Eric”));
Persons[0].Childs = new List<Person>();
Persons[0].Childs.Add(new Person(“Tom”));
Persons[0].Childs.Add(new Person(“John”));
Persons[0].Childs[0].Childs = new List<Person>();
Persons[0].Childs[0].Childs.Add(new Person(“Bill”));
Persons.Add(new Person(“John”);

Now I have this class:

public class Human
{
public string Name { get; set; }

public int Age { get; set; }

public List&lt;Human&gt; SubHuman { get; set; }

}

Lets say the Persons list was created. How can I now create a new list Humans out of the Persons list (iterate over the list) whereas the name of each Human is the name of the appropriate Person?

#c-sharp

2 Likes2.35 GEEK