Exemple #1
0
        static void Main()
        {
            Console.WriteLine("pi is" + MathTest.GetPi());
            int x = MathTest.GetSquareOf(5);

            Console.WriteLine("Square of 5 is" + x);
            MathTest math = new MathTest();

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

            math.value = 30;
            Console.WriteLine("Value field of math variable contains " + math.value);
            Console.WriteLine("Square of 30 is " + math.GetSquare());
        }
Exemple #3
0
        static void Main()
        {
            // Calling some static functions, A static function, unlike a regular (instance) function, is not associated with an instance of the class.
             Console.WriteLine("Pi is " + MathTest.GetPi());
             int x = MathTest.GetSquareOf(5);  //#important# A static member cannot be referenced through an instance. Instead, it is referenced through the type name
             //int y = MathTest.GetSquare(); // won't compile as GetSquare is a non-static method
             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());
        }
Exemple #4
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();


            math.Value = 30;
            Console.WriteLine(
                "Value field of math variable contains " + math.Value);
            Console.WriteLine("Square of 30 is " + math.GetSquare());
        }
Exemple #5
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
            MathTest math = new MathTest();

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

            Dimensions instance;

            instance.Length = 5.0;
            instance.Width  = 6.0;
            Console.WriteLine("Area of Dimensions's instance is " + MathTest.GetArea(ref instance));

            //DateTime date1 = new DateTime(2008, 3, 1, 7, 0, 0);
            //Console.WriteLine(date1.ToString(System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR")));
            DateTime date1 = DateTime.Now;

            Console.WriteLine(date1.ToString(System.Globalization.CultureInfo.InvariantCulture));
            // Displays 01/03/2008 07:00:00

            var captain = new { FirstName = "James", MiddleName = "T", LastName = "Krik" };

            Console.WriteLine(captain);

            int    i   = -50;
            string str = i.ToString();
        }