コード例 #1
0
        // 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());
        }
コード例 #2
0
ファイル: DelegateTest2.cs プロジェクト: Tob1112/seungbeomi
        // 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());
        }