private List<Book> returnBook() { int n = dataGridView1.RowCount; Book b = null; for (int x = 0; x < n - 1; x++) { try { int bookId = int.Parse(dataGridView1.Rows[x].Cells[0].ToString()); string bookName = dataGridView1.Rows[x].Cells[1].ToString(); int bookPrice = int.Parse(dataGridView1.Rows[x].Cells[2].ToString()); b = new Book(bookId,bookName,bookPrice); } catch (Exception xe) { MessageBox.Show(xe.Message); } lbo.Add(b); } return lbo; }
最后显示的是你添加的数据类型不正确.请各位高手帮帮我啊!
|