Example #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 a MathTest object
            //this is C#'s way of instantiating a reference type.
            MathTest math = new MathTest();

            // Call nonstatic methods
            math.value = 30;
            Console.WriteLine("Value field of math variable contains " + math.value);
            Console.WriteLine("Square of 30 is " + math.GetSquare());
        }
Example #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 a MathTest object
            //this is C#'s way of instantiating a reference type.
            MathTest math = new MathTest();

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