コード例 #1
0
ファイル: Program.cs プロジェクト: johndarv/DelegatesExample
        static void Main(string[] args)
        {
            BigMassiveRocket rocket = new BigMassiveRocket();
            BigRedButton     button = new BigRedButton();

            button.RegisterHandler(rocket.Launch);

            string userInput = string.Empty;

            while (userInput != "q")
            {
                if (userInput == "push")
                {
                    button.Push();
                }

                userInput = Console.ReadLine();
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            BigMassiveRocket rocket = new BigMassiveRocket();
            BigRedButton     button = new BigRedButton(rocket.Launch);

            string userInput = string.Empty;

            while (userInput != "q")
            {
                if (userInput == "push")
                {
                    Action pushMethod = button.Push;

                    pushMethod();
                }

                userInput = Console.ReadLine();
            }
        }