Untitled
unknown
plain_text
4 years ago
1.0 kB
13
Indexable
class LinkList
{
private Journals list = null; //default value – empty list
public void AddItem(int item) //add item to front of list
{
list = new Journals(item, this.list);
}
public string DisplayItems() //write items to string and return
{
Journals temp = list;
string buffer = "";
while (temp != null) // move one link and add head to the buffer
{
buffer = buffer + temp.Data + ",";// use this instead of console.writeline as this can be viewed in gui not only console apps
temp = temp.Next;
}
return buffer;
}
public partial class Form1 : Form
{
private LinkedList<string> myList = new LinkedList<string>();
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
myList.DisplayItems();
}
Editor is loading...