コード例 #1
0
    public void Run()
    {
        int option;

        do
        {
            ShowMenu();
            option = Convert.ToInt32(Console.ReadLine());
            switch (option)
            {
            case 1:
                SalesModule sales = new SalesModule();
                sales.Run();
                break;

            case 2:
                AdminModule admin = new AdminModule();
                admin.Run();
                break;

            case 0:
                Console.WriteLine("Bye!");
                Console.WriteLine();
                break;

            default:
                Console.WriteLine("Wrong option");
                Console.WriteLine();
                break;
            }
        }while (option != 0);
    }
コード例 #2
0
    public void Run()
    {
        Int32 number;

        do
        {
            ShowMenu();
            bool cFormat = Int32.TryParse(Console.ReadLine(), out number);

            // Incorrect Format
            if (!cFormat)
            {
                number = 10;
            }

            switch (number)
            {
            case 1:
                SalesModule sales = new SalesModule();
                sales.Run();
                break;

            case 2:
                AdminModule admin = new AdminModule();
                admin.Run();
                break;

            case 3:
                CreditsScreen.Display();
                break;

            case 0:
                Console.SetCursorPosition(Console.WindowWidth / 2 - 3,
                                          Console.WindowHeight / 2);
                Console.WriteLine("Bye");
                break;

            default:
                Console.WriteLine("Wrong option");
                Console.WriteLine();
                break;
            }
        }while (number != 0);
    }