示例#1
0
        public DivideAnswer Divide3(int number1, int number2)
        {
            DivideAnswer answer = new DivideAnswer();

            answer.Value     = number1 / number2;
            answer.Remainder = number1 % number2;
            return(answer);
        }
示例#2
0
        } //* End Main

        // The readString method will read text and make sure that the user does not enter
        // empty text.
        //static string readString(string prompt)
        //{
        //    string result;
        //    do
        //    {
        //        Console.Write(prompt);
        //        result = Console.ReadLine();

        //    } while (result == "");
        //    return result;
        //}

        //// The readInt mthod reads a number within a particular range.   The
        //// method uses the readString method in the readInt one, so that the
        //// user can't enter an empty string when a number is required.
        //static int readInt(string prompt, int low, int high)
        //{
        //    int result;
        //    do
        //    {
        //        string intString = readString (prompt);
        //        result = int.Parse(intString);

        //    } while ((result < low || result > high));
        //    return result;

        //}
        //static void RunSimpleMath()
        //{
        //    /* This is a commment line */
        //    Console.WriteLine("Running SimpleMath");
        //    MathOps test = new MathOps();
        //    decimal answer = test.Add(2, 2);
        //    Console.WriteLine("The Add method returned 2 + 2 = " + answer);
        //    Console.WriteLine("2 + 3= " + new MathOps().Add(2, 3).ToString());
        //    Console.WriteLine("3 - 2= " + new MathOps().Subtract(2, 3).ToString());
        //    Console.WriteLine("2 * 3= " + new MathOps().Multiply(2, 3).ToString());
        //    Console.WriteLine("2/3  = " + new MathOps().Divide(2, 3).ToString());
        //    Console.ReadKey();
        //}



        static void RunwithDivideAnswer()
        {
            Console.Clear();
            Console.WriteLine("\nRunwithDivideAnswer");
            Console.WriteLine("\nDefined as public 'Divide Answer'. Divide Answer is a class that   ");
            Console.WriteLine("is returned.                                                         ");
            Console.WriteLine("                                                                    ");
            Console.WriteLine("                                                                 ");
            var          simpleMath = new MathOps();
            DivideAnswer ans        = simpleMath.Divide3(15, 6);

            Console.WriteLine("answer " + ans.Value);
            Console.WriteLine("remainder " + ans.Remainder);
            Console.Write("\nPress ENTER to Continue ");
            Console.ReadKey();
        }