コード例 #1
0
ファイル: MathTest.cs プロジェクト: alannet/example
        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());
        }
コード例 #2
0
ファイル: MathTest.cs プロジェクト: taozididi/example
        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());
        }