static void Main(string[] args) { Node node = new Node(10); node.next = new Node(2); node.next.next = new Node(14); node.next.next.next = new Node(5); node.Print(); Console.ReadKey(); }
public void Print() { if (next != null) { Console.Write(" | " + data + " | " + "->"); next.Print(); } else { Console.WriteLine(" | " + data + " | "); } }
public void Print() { if (headNode != null) { headNode.Print(); } else { Console.Write("Empty LinkedList!"); } Console.WriteLine(); }
public void Print() { if (next != null) { Console.Write(data + ","); if (next != null) { next.Print(); } } else { Console.Write(data); } }
static void Main(string[] args) { //creates a new Node with a head value of 7 Node myNode = new Node(7); // adds a new node in myNode by updating Nodes pointer value and creating a new node with the new data and new pointer // this is not scalable myNode.next = new Node(5); //better way is to use the new method AddToEnd myNode.AddToEnd(12); myNode.AddToEnd(15); // call print method myNode.Print(); }
public void Print() { _headNode?.Print(); }