I'm trying to use TreeNodes to create a Tree like structure in code. I'm not all that familiar with TreeNodes at all. I did some searching beforehand but I still don't feel like I understand exactly what I am doing.
I am creating a Game in Unity using C#. I'm using XML to create dialogue and I want to store the different options from the different choices in a Tree-like structure.
A visual representation of this would be like:
-------------------------------choice a --------------------------- choice b --------------------------------
/--------|--------\ /--------|--------\
choice d choice e choice f choice g choice h choice i
and so on.
public class TreeNode<T> : IEnumerable<TreeNode<T>>
{
public T Data {get; set;}
public TreeNode<T> Parent { get; set; }
public ICollection<TreeNode<T>> Children {get; set;}
public TreeNode(T data) {
this.Data = data;
this.Children = new LinkedList<TreeNode<T>>();
}
public TreeNode<T> AddChild(T child) {
TreeNode<T> childNode = new TreeNode<T>(child) {Parent = this};
this.Children.Add (childNode);
return childNode;
}
}
Currently I am getting the error TreeNode<T>' does not implement interface member
System.Collections.Generic.IEnumerable>.GetEnumerator()'.
I'm not entirely sure what that error even means, any help would be appreciated.
My first time posing a question in StackOverFlow so if this is in the wrong spot, please let me know.
Thanks