This Class generate Nodes and can add a new Node to the List
using System;
namespace ConsoleApplication2
{
public class LinkedList
{
private class Node
{
public object Data;
public Node Next;
}
// Set first and last Node
private Node first;
private Node last;
//Count Nodes
public int Count { get; private set; }
//Add´s a new Node
public void Add(object data)
{
Node newNode = new Node() { Data = data };
if (first == null)
{
first = newNode;
last = newNode;
}
else
{
last.Next = newNode;
last = newNode;
}
Count++;
}
}
}
2 Kommentare zum Snippet