How to get a List from a public void method

  • Thread starter Thread starter MorenainHanoi
  • Start date Start date
M

MorenainHanoi

Guest
I have saved a book using a public void method:

myLibrarian.SaveBook(newBook);

So my newBook is saved, and i want to show the list of saved books that i made. I also have a public void method for it:

myLibrarian.GetBook(newBook);

My question is how do i make an instance where it will show me the complete list of books that i saved?



public class Librarian
{
private List<Book> bookList = new List<Book>();
public void SaveBook(Book book)
{
bookList.Add(book);
}

public void GetBook(Bok allBook)
{
foreach (Book book in bokList)
{
Console.WriteLine(book.ToString());
}
}
}

Continue reading...
 
Back
Top