Try this:
using System;
using System.Collections;
using System.Windows.Forms;
namespace BookstoreTest
{
public partial class Form1 : Form
{
ArrayList bookstore;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
bookstore = new ArrayList();
setUpBookStore();
}
private void btnBkStock_Click(object sender, EventArgs e)
{
showListOfBooks();
}
private void setUpBookStore()
{
bookstore.Add(new Book1("Spills", "Kendrick Williermson", "2015", "5", "4532145321"));
bookstore.Add(new Book1("Ken", "Lierm Pattasun", "1903", "20", "1235412354"));
bookstore.Add(new Book1("A Secret Chamber", "Harry Potter", "0000", "10000000", "1111111111"));
bookstore.Add(new Book1("Eddie", "Rik Mayall", "2000", "31", "7483758376"));
bookstore.Add(new Book1("Stella the Tortoise", "BL. Ager", "1519", "223", "0003200067"));
}
private void showListOfBooks()
{
lstBooks.Items.Clear();
foreach (Book1 b in bookstore)
{
lstBooks.Items.Add(b.Title + "by" + b.Author + ". Isbn: " + b.ISBN + "Year: " + b.Year + "." + Environment.NewLine);
}
}
}
public class Book1
{
public string Title
{
get;
set;
}
public string Author
{
get;
set;
}
public string Year
{
get;
set;
}
public string Month
{
get;
set;
}
public string ISBN
{
get;
set;
}
public Book1(string _Title, string _Author, string _Year, string _Month, string _ISBN)
{
this.Title = _Title;
this.Author = _Author;
this.Year = _Year;
this.Month = _Month;
this.ISBN = _ISBN;
}
}
}