static void Main(string[] args) { Console.WriteLine("请输入笔记本品牌:"); string brand = Console.ReadLine(); NoteBook nb = GetNoteBook(brand); nb.SayHello(); Console.ReadKey(); }
static void Main(string[] args) { while (true) { Console.WriteLine("请输入笔记本品牌:"); string brand = Console.ReadLine(); try { if (brand.Equals("end", StringComparison.OrdinalIgnoreCase)) { break; } NoteBook nb = GetBook(brand); nb.SayHello(); Console.ReadKey(); } catch (Exception) { } } }