Beispiel #1
0
        static void Main()
        {
            //Class1.Display()  You can not colled that
            class1 o;         // o is a reference of type Class1

            o = new class1(); // Allocate memory for an object of type Class1 and make o point to it

            //class1 o = new class1();
            o.Display();
            o.Display("Rahul");

            //Positional parameters
            Console.WriteLine(o.Add(10, 20, 30, 40));
            Console.WriteLine(o.Add(10, 20, 30));
            Console.WriteLine(o.Add(10, 20));
            Console.WriteLine(o.Add(10));
            Console.WriteLine(o.Add());

            // Named Parametsre
            Console.WriteLine(o.Add(d: 40));
            Console.WriteLine(o.Add(c: 30));
            Console.WriteLine(o.Add(d: 40, c: 30));


            //Add2
            //Console.WriteLine(o.Add2(d: 40));
            Console.WriteLine(o.Add2(d: 40, a: 40, b: 40, c: 40));



            Console.ReadLine();
        }
Beispiel #2
0
        static void Main()
        {
            // class1 o;   // o  is a ref of type Class1
            // o = new class1();  // allocate memory for an obj of type class1 and make to point to it.

            class1 o = new class1();

            o.Display();
            o.Display("Shradha");


            // positional parameters
            Console.WriteLine(o.Add(10, 20, 30, 40));
            Console.WriteLine(o.Add(10, 20, 30));
            Console.WriteLine(o.Add(10, 20));
            Console.WriteLine(o.Add(10));
            Console.WriteLine(o.Add());
            Console.WriteLine();

            //named parameters
            Console.WriteLine(o.Add(d: 40));
            Console.WriteLine(o.Add(c: 30));
            Console.WriteLine(o.Add(d: 40, c: 30));


            //Console.WriteLine(o.Add2(d: 40));   // Error
            //Console.WriteLine(o.Add2(a: 30));   // Error
            Console.WriteLine(o.Add2(d: 40, c: 30, a: 40, b: 30));

            Console.ReadLine();
        }