Example #1
0
 public void AddNode(int data)
 {
     if (Next == null)
     {
         Next = new LinkedListNode(data);
     }
     else
     {
         Next.AddNode(data);
     }
 }
        /// <summary>
        /// Uses recursion to check if "head" is null. If it is it will start the list with a new node
        /// else it will call the AddNode method in the Node class which will check if the next value is
        /// null. If it is it will point next to a new node else it will iterate through to the end.
        /// </summary>
        /// <param name="value">int value of the node</param>

        public void AddToEnd(int value)
        {
            if (Head == null)
            {
                Head = new LinkedListNode(value);
            }
            else
            {
                Head.AddNode(value);
            }
        }