//第 0 個參數佔 30 字元(靠右); 第 1 個參數格式化為 #.## //{ System.Console.WriteLine("{0,30} = {1:#.##}", b.Title, b.Price); } //http://blog.csdn.net/xrongzhen/article/details/5477075 // Execution starts here. static void Main() { BookDB bookDB = new BookDB(); //為命名空間 Bookstore 之類別 BookDB 建立實體 // Initialize the database with some books: bookDB.AddBook("The C Programming Language", "Brian W.", 19.95m, true); bookDB.AddBook("The Unicode Standard 2.0", "The Unicode Consortium", 39.95m, true); System.Console.WriteLine("Paperback Book Titles:"); // Create a new delegate object associated with the static // method PrintTitle: 指向靜態方法之委派 bookDB.ProcessPaperbackBooks(PrintTitle); //書籍名稱 (逐本處理) // Get the average price of a paperback by using a PriceTotaller object: PriceTotaller totaller = new PriceTotaller(); //為類別 PriceTotaller 建立實體(價格加總) // Create a new delegate object associated with the nonstatic // method AddBookToTotal on the object totaller: 指向非靜態方法之委派 bookDB.ProcessPaperbackBooks(totaller.AddBookToTotal); //書籍加總 (逐本處理) System.Console.WriteLine("Average Paperback Book Price: ${0:#.##}", totaller.AveragePrice()); string nop = System.Console.ReadLine(); }
// 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); }
private static void AddBooks(BookDB bookDB) { bookDB.AddBook("The C Programming Lanugage", "Brian W. Kernigham and Dennis M. Ritchie", 19.95m, true); bookDB.AddBook("Default book title 1", "Default author(s) 1", 22.95m, true); bookDB.AddBook("Default book title 2", "Default author(s) 2", 99.95m, false); bookDB.AddBook("Default book title 3", "Default author(s) 3", 35.95m, true); }
static void AddBooks(BookDB bookDB) { //(string title, string author, decimal price, DateTime publish_date, string description, bool paperBack, string isbn10, string isbn13) bookDB.AddBook("The C Programming Language", "Brian W. Kernighan and Dennis M. Ritchie", 19.95m, new DateTime(1988, 3, 22), "hoge", true, "0131103628", "978-0131103627"); bookDB.AddBook("The Unicode Standard 2.0", "The Unicode Consortium", 39.95m, new DateTime(2000, 10, 01), "fuga", true, "0131103628", "978-0131103627"); bookDB.AddBook("The MS-DOS Encyclopedia", "Ray Duncan", 129.95m, new DateTime(2000, 10, 01), "piyo", false, "0131103628", "978-0131103627"); bookDB.AddBook("Dogbert's Clues for the Clueless", "Scott Adams", 12.00m, new DateTime(2000, 10, 01), "piyopiyo", true, "0131103628", "978-0131103627"); }
//Initalize the book databases with some test books: static void AddBooks(BookDB bookDB) { bookDB.AddBook("Programming in C ", "Dennis Retchie", 19.95m, true); bookDB.AddBook("Database Design", "Korth", 50.0m, true); bookDB.AddBook("Compiler Design", "Aho Ulman Lam Sethi", 33.0m, false); }