c# - Trying to add data to my List<book> but getting "No overload for method takes 2 arguements". What can I do? -


i making bookshelf application , having issue trying add data list. here code having trouble with:

static list<book> book = new list<book>(); public void addbook() {     int bookquantity;      string booktitle, bookauthor;      bookquantity = int.parse(console.readline());      for(int x = 0; x <= bookquantity; x++)     {         console.writeline("enter title.");         booktitle = console.readline();          console.writeline("enter author.");         bookauthor = console.readline();          library.add(booktitle, bookauthor);     } } 

when running, error "no overload method 'add' takes 2 arguements." help/advice welcome. thank in advance.

you need change:

library.add(booktitle, bookauthor); 

to

book.add(new book() { title = booktitle, author = bookauthor} ); 

or

book.add(new book(booktitle, bookauthor ); //if have relevant constructor 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -