I have the below class for generating Hierarchy Tree structure
public class DynaTreeNode
{
#region---Property---
public string title { get; set; }
public string key { get; set; }
public object icon { get; set; }
List<DynaTreeNode> _children = new List<DynaTreeNode>();
public List<DynaTreeNode> children
{
get { return _children; }
set { _children = value; }
}
}
Also i have a list of DynaTreeNode
List<DynaTreeNode> wholeTree = new List<DynaTreeNode>();//originally from DB
Now i want to clone this List collection into a new List
Todo this I am thinking to use
wholeTree.Select(i => i.Clone()).ToList();
In this case i need to implement IClonable Interface to DynaTreeNode. But the problem is IClonable will not do a deep copy. From http://blogs.msdn.com/b/brada/archive/2003/04/09/49935.aspx
Referred How do I clone a generic list in C#?
This answer also use IClonable.
How can I clone my List with deep copy?.
Note: I want all the children (List) also should get cloned.