I have these objects from "book" class in a list (BLibShelf) but would like to start adding them to such list with console input
namespace Library
{
class Program
{
static void Main(string[] args)
{
Book book1 = new Book("book one", "Author one", 900, 35, 16);
Book book2 = new Book("book two", "Author two", 240, 42, 8);
Book book3 = new Book("book three", "Author three", 700, 23, 8);
List<Book> BLibShelf = new List<Book>();
BLibShelf.AddRange(new List<Book>() { book1, book2, book3, book4, book5, book6, book7, book8 });
Console.ReadLine();
}
}
here is my book class
class Book
{
public string title;
public string author;
public int pages;
public int Libcopies;
public int BCopies;
public Book(string nTitle, string nAuthor, int nPages, int nLcopies, int nBcopies)
{
title = nTitle;
author = nAuthor;
pages = nPages;
Libcopies = nLcopies;
BCopies = nBcopies;
}
var title = Console.ReadLine();then use these variables in the constructor to make a new bookvar book = new Book(title, author....);and then add it to the list usingBLibShelf.Add(book);