コード例 #1
0
 public void AddB(Book nbook)
 {
     Book[] nbooks = new Book[_numOfBooks + 1];
     for (int i = 0; i < _numOfBooks; i++)
     {
         nbooks[i]      = new Book();
         nbooks[i].Name = _books[i].Name;
         nbooks[i].Num  = _books[i].Num;
         nbooks[i].Year = _books[i].Year;
     }
     nbooks[_numOfBooks] = (Book)nbook.Clone();
     _books = nbooks;
     _numOfBooks++;
     Sort();
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: liking1/UpdatedLibrary
        public void AddBook(Book book)
        {
            if (this.books == null)
            {
                Console.WriteLine($"fdsfdfs");
                books    = new Book[1];
                books[0] = (Book)book.Clone();
                return;
            }
            Book[] tmp = (Book[])books.Clone();
            books = new Book[books.Length + 1];

            for (int i = 0; i < books.Length - 1; i++)
            {
                books[i] = (Book)tmp[i].Clone();
            }
            Book book1 = book;

            books[books.Length - 1] = book1;
        }