C#C
C#4y ago
xyrile

Iterator (Argument 1 cannot convert from 'Coding.Exercise.Nodechar[]' to 'char*' Compilation failed)

public class Node<T>
    {
        public T value;
        public Node<T> left, right, parent;

        public Node(T value)
        {
            this.value = value;
        }

        public Node(T value, Node<T> left, Node<T> right)
        {
            this.value = value;
            this.left = left;
            this.right = right;

            left.parent = right.parent = this;
        }

        public IEnumerable<Node<T>> PreOrder
        {
            get
            {
                return new PreOrderIterator<T>(this);
            }
        }
    }
    public class PreOrderIterator<T> : IEnumerable<Node<T>>
    {
        private Stack<Node<T>> stack = new Stack<Node<T>>();
        public PreOrderIterator(Node<T> root)
        {
            stack.Push(root);
        }
        public IEnumerator<Node<T>> GetEnumerator()
        {
            foreach (Node<T> node in stack)
            {
                yield return node;
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }
    }


Can someone help me with this ? this is preorder Traverse
Was this page helpful?