static void Main(string[] args)
        {
            //Delegate Instances Created
            CalculateDel multiCastDel = new CalculateDel(addDel, addDel, multDel, divDel);

            CalculateDel addDel  = new CalculateDel(Add);
            CalculateDel subDel  = new CalculateDel(Subtract);
            CalculateDel multDel = new CalculateDel(Multiply);
            CalculateDel divDel  = new CalculateDel(Divide);

            //User Prompt
            double num1 = Convert.ToDouble(Console.ReadLine());
            double num2 = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Enter the first number: \nEnter the second number: ", num1, num2);
        }
        static void Main(string[] args)
        {
            //Delegate Instances Created
            CalculateDel multiCastDel = new CalculateDel(addDel, addDel, multDel, divDel);

            CalculateDel addDel = new CalculateDel(Add);
            CalculateDel subDel = new CalculateDel(Subtract);
            CalculateDel multDel = new CalculateDel(Multiply);
            CalculateDel divDel = new CalculateDel(Divide);

            //User Prompt
            double num1 = Convert.ToDouble(Console.ReadLine());
            double num2 = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Enter the first number: \nEnter the second number: ", num1, num2);

            
        }
예제 #3
0
        public static void Main(string[] args)
        {
            double num1, num2;

            WelcomeMessage();
            FirstInputMessage();
            num1 = Convert.ToDouble(Console.ReadLine());
            if (num1 == -1)
            {
                QuitMessage();
            }
            else
            {
                SecondInputMessage();
                num2 = Convert.ToDouble(Console.ReadLine());
                while (true)
                {
                    // Creating & Invoking Delegate Instances ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                    //Muticasting all 4 delegates objects
                    CalculateDel myCalculateDel = null;
                    myCalculateDel = myCalculateDel + addDel + subDel + multDel + divDel;
                    myCalculateDel(num1, num2);

                    FirstInputMessage();
                    num1 = Convert.ToDouble(Console.ReadLine());
                    if (num1 == -1)
                    {
                        QuitMessage();
                        break;
                    }//End if
                    SecondInputMessage();
                    num2 = Convert.ToDouble(Console.ReadLine());
                } //End While
            }     //End else
            Console.Read();
        }         //End Main