public CBook(CBook book) //copy constructor { strTitle = book.Title; strAuthor = book.Author; strPublisher = book.Publisher; nPublishDate = book.PublishDate; }
private void Additems() { firstBook = new CBook(); firstBook.Title = txtTitle.Text; firstBook.Author = txtAuthor.Text; firstBook.Publisher = txtPublisher.Text; firstBook.PublishDate = Int32.Parse(txtPublished.Text); arrBooks.Add(firstBook); ShowAll(); txtTitle.Text = ""; txtAuthor.Text = ""; txtPublisher.Text = ""; txtPublished.Text = ""; }
public void LoadBookList() { // a book using the default constructor firstBook = new CBook(); firstBook.Title = "The Lord of the Rings"; firstBook.Author = "JRR Tolkien"; firstBook.Publisher = "Penguin"; firstBook.PublishDate = 1935; arrBooks.Add(firstBook); //a book using the custom one-step constructor currBook = new CBook("Sharpe's Rifles", "Bernard Cornwell", "Harper Collins", 1987); arrBooks.Add(currBook); //a book using the copy constructor – you’ll have two books the same currBook = new CBook(firstBook); arrBooks.Add(currBook); }