Beispiel #1
0
        static void Main()
        {
            // Try calling some static functions
             Console.WriteLine("Pi is " + MathTest.GetPi());
             int x = MathTest.GetSquareOf(5);
             Console.WriteLine("Square of 5 is " + x);

             // Instantiate at MathTest object
             MathTest math = new MathTest();   // this is C#'s way of
                                           // instantiating a reference type

             // Call non-static methods
             math.value = 30;
             Console.WriteLine(
            "Value field of math variable contains " + math.value);
             Console.WriteLine("Square of 30 is " + math.GetSquare());
        }
Beispiel #2
0
        static void Main()
        {
            // Try calling some static functions
            Console.WriteLine("Pi is " + MathTest.GetPi());
            int x = MathTest.GetSquareOf(5);

            Console.WriteLine("Square of 5 is " + x);

            // Instantiate at MathTest object
            MathTest math = new MathTest(); // this is C#'s way of

            // instantiating a reference type

            // Call non-static methods
            math.value = 30;
            Console.WriteLine(
                "Value field of math variable contains " + math.value);
            Console.WriteLine("Square of 30 is " + math.GetSquare());
        }