Пример #1
0
        static void Main(string[] args)
        {
            DoThis();
            DoThisAswell();
            var m = new Mammal(); // m is an INSTANCE (REAL EXAMPLE) of class mammal

            m.GetOlder();         // INCREASE AGE TO 1

            // method INSIDE method
            void DoThis()
            {
                Console.WriteLine("I am doing something");
            }

            CountNumbers(5000);       // y only
            CountNumbers(5000, 300);  // y and x

            OutParameters(10, 10, out int a);
            Console.WriteLine($"out parameter was {a}");

            TupleMethod();                   // Not gathering output; output is wasted

            var tupleOutput = TupleMethod(); // OUTPUT Sent to custom object

            Console.WriteLine($"{tupleOutput.x}, {tupleOutput.y},{tupleOutput.z}");
        }
Пример #2
0
        static void Main(string[] args)
        {
            DoThisEveryday();
            // method INSIDE method
            DoThisAswell();
            var m = new Mammal();

            m.GetOlder(); // increase age by 1
            void DoThisEveryday()
            {
                Console.WriteLine("I am doing this");
            }

            CountNum(5000); // y only
            CountNum(5000, 300);


            OutParameters(10, 10, out int a);
            Console.WriteLine($"output: {a}");

            TupleMethod();                   // not gathering the output
            var tupleOutput = TupleMethod(); // OUTPUT sent to custom object

            Console.WriteLine($"tupleOutputs are {tupleOutput.x}, {tupleOutput.y}, {tupleOutput.z}");
        }
Пример #3
0
        static void Main(string[] args)
        {
            DoThis();
            DoThisAswell();

            var mammal = new Mammal();

            mammal.GetOlder();

            //Method INSIDE method
            void DoThis()
            {
                Console.WriteLine("Do this...");
            }

            CountNumbers(5000);      //y only
            CountNumbers(5000, 300); //y and x

            OutParamters(10, 10, out int a);
            Console.WriteLine($"out parameter was {a}");

            TupleMethod();//not using the output. output is wasted
            var tupleOutput = TupleMethod();

            Console.WriteLine($"{tupleOutput.x}, {tupleOutput.y}, {tupleOutput.z}");
        }
        static void Main(string[] args)
        {
            DoThis();//calls the dothis method
            DoThisAswell();
            Mammal m = new Mammal();

            m.GetOlder();

            //method inside another method
            void DoThis()
            {
                Console.WriteLine("doing something!");
            }

            CountNumbers(5000);
            CountNumbers(5000, 300);

            OutParameters(10, 10, out int a);
            Console.WriteLine($"out paramter was {a}");

            var tupleOutput = TupleMethod();

            Console.WriteLine($"{tupleOutput.x}, {tupleOutput.y}, {tupleOutput.z}");
        }