Пример #1
0
 public void AddToEnd(int data)
 {
     if (headNode == null)
     {
         headNode = new Node(data);
     }
     else
     {
         headNode.AddToEnd(data);
     }
 }
Пример #2
0
 public void AddToEnd(int data)
 {
     if (next == null)
     {
         next = new Node(data);
     }
     else
     {
         next.AddToEnd(data);
     }
 }
Пример #3
0
 public void AddToEnd(int data)
 {
     if (headNode == null)
     {
         headNode = new Node(data);
     }
     else
     {
         //using recursion, method is calling itself until the condition is met
         headNode.AddToEnd(data);
     }
 }
Пример #4
0
 public void AddToEnd(int data)
 {
     // In this case we know that this is the end of the list, so we just add a new Node!
     if (next == null)
     {
         next = new Node(data);
     }
     else
     {
         // recursive call (passa the responsibility down to the chain, until "next" == null)!
         next.AddToEnd(data);
     }
 }