Пример #1
0
 private static void RegisterBook(List<Book> bookList)
 {
     Console.Write("Entre el identificador del libro: ");
     string code = Console.ReadLine();
     Console.Write("Entre el título del libro: ");
     string title = Console.ReadLine();
     Book book = new Book(title, code);
     if (!bookList.Contains(book))
     {
         bookList.Add(book);
         Console.WriteLine("Libro registrado correctamente.");
     }
     else Console.WriteLine("Libro ya existente!");
 }
Пример #2
0
 public List<Book> GetAllBooks()
 {
     string line;
     List<Book> bookList = new List<Book>();
     StreamReader file = new StreamReader("C:\\Books.txt");
     while ((line = file.ReadLine()) != null)
     {
         string[] lines = line.Split('\t');
         Book aux = new Book(lines[1], lines[0], bool.Parse(lines[2]));
         bookList.Add(aux);
     }
     file.Close();
     return bookList;
 }