static void Main() // Выполнение начинается здесь. { BookDB bookDB = new BookDB(); AddBooks(bookDB); // Инициализация базы данных с использованием нескольких книг: Console.WriteLine("Paperback Book Titles:"); // Печать названий всех книг в бумажной обложке: // Создание нового объекта делегата, связанного со статическим методом Test.PrintTitle: bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle)); // Получение средней цены книги в бумажной обложке при помощи объекта PriceTotaller: PriceTotaller totaller = new PriceTotaller(); // Создание нового объекта-делегата, связанного с нестатическим объектом // методом AddBookToTotal объекта суммарных показателей: bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(totaller.AddBookToTotal)); Console.WriteLine("Average Paperback Book Price: ${0:#.##}", totaller.AveragePrice() ); }
// Execution starts here. static void Main( ) { BookDB bookDB = new BookDB( ); // Initialize the database with some books: AddBooks( bookDB ); // Print all the titles of paperbacks: Console.WriteLine( "Paperback Book Titles:" ); // Create a new delegate object associated with the static // method Test.PrintTitle: bookDB.ProcessPaperbackBooks( new ProcessBookDelegate( PrintTitle ) ); // Get the average price of a paperback by using // a PriceTotaller object: PriceTotaller totaller = new PriceTotaller( ); // Create a new delegate object associated with the nonstatic // method AddBookToTotal on the object totaller: bookDB.ProcessPaperbackBooks( new ProcessBookDelegate( totaller.AddBookToTotal ) ); Console.WriteLine( "Average Paperback Book Price: ${0:#.##}", totaller.AveragePrice( ) ); }
// Initialize the book database with some test books: static void AddBooks( BookDB bookDB ) { bookDB.AddBook( "The C Programming Language", "Brian W. Kernighan and Dennis M. Ritchie", 19.95m, true ); bookDB.AddBook( "The Unicode Standard 2.0", "The Unicode Consortium", 39.95m, true ); bookDB.AddBook( "The MS-DOS Encyclopedia", "Ray Duncan", 129.95m, false ); bookDB.AddBook( "Dogbert's Clues for the Clueless", "Scott Adams", 12.00m, true ); }
static void AddBooks(BookDB bookDB) // Инициализация базы данных книг с использованием нескольких тестовых книг: { bookDB.AddBook("The C Programming Language", "Brian W. Kernighan and Dennis M. Ritchie", 19.95m, true); bookDB.AddBook("The Unicode Standard 2.0", "The Unicode Consortium", 39.95m, true); bookDB.AddBook("The MS-DOS Encyclopedia", "Ray Duncan", 129.95m, false); bookDB.AddBook("Dogbert's Clues for the Clueless", "Scott Adams", 12.00m, true); }
// 下面开始执行。 static void Main() { BookDB bookDB = new BookDB(); // 用一些书初始化数据库: AddBooks(bookDB); // 打印所有平装本的书名: Console.WriteLine("Paperback Book Titles:"); // 创建一个与静态方法 Test.PrintTitle 关联的 // 新委托对象: bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle)); // 使用 PriceTotaller 对象 // 获取平装本的平均价格: PriceTotaller totaller = new PriceTotaller(); // 创建一个与对象 totaller 的非静态方法 // AddBookToTotal 关联的新委托对象: bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(totaller.AddBookToTotal)); Console.WriteLine("Average Paperback Book Price: ${0:#.##}", totaller.AveragePrice()); }
static void Main() { BookDB bookDB = new BookDB(); AddBooks(bookDB); Console.WriteLine("Paperback Book Titles:"); bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle)); PriceTotaller totaller = new PriceTotaller(); bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(totaller.AddBookToTotal)); Console.WriteLine("Average Paperback Book Price: ${0:#.##}", totaller.AveragePrice()); Console.ReadLine(); }