Exemple #1
0
        public void Main()
        {
            Console.WriteLine("Function Overloading \n");
            Console.WriteLine("Function overloading allows multiple implementations of the same function in a class. " +
                              "Overloaded methods share the same name but have a unique signature. The number of parameters, types of parameters or both must be different. " +
                              "A function can't be overloaded on the basis of a different return type alone. ");

            FunctionOverloading obj = new FunctionOverloading();

            obj.setName("barack");
            Console.WriteLine(obj.name);
            obj.setName("barack ", " obama ");
            Console.WriteLine(obj.name);
            Console.WriteLine(obj.setName("barack ", "hussian", "obama"));
            Console.WriteLine("------------------------------------------------------------------------");
        }
Exemple #2
0
        private static void OOPOverview()
        {
            Console.WriteLine("(1) Classes and Objects");
            Console.WriteLine("(2) Creating and accessing Class Component Library");
            Console.WriteLine("(3) Constructor and Destructor");
            Console.WriteLine("(4) Function Overloading");
            Console.WriteLine("(5) Encapsulation");
            Console.WriteLine("(6) Inheritance");
            Console.WriteLine("(7) Virtual and Hiding Methods");
            Console.WriteLine("(8) Abstract Classes");
            Console.WriteLine("(9) Sealed Classes");
            Console.WriteLine("(10) Interface");
            Console.WriteLine("(11) Polymorphism");
            var result = Console.ReadLine();

            switch (result)
            {
            case "1":
                var a = new OOP.ClassesAndObjects();
                a.Main();
                break;

            case "2":
                var b = new OOP.CreatingClassLibrary();
                b.Main();
                break;

            case "3":
                var c = new OOP.ConstructorAndDestructor();
                c.Main();
                break;

            case "4":
                var d = new OOP.FunctionOverloading();
                d.Main();
                break;

            case "5":
                var e = new OOP.Encapsulation();
                e.Main();
                break;

            case "6":
                var f = new OOP.Inheritance();
                f.Main();
                break;

            case "7":
                var g = new OOP.VirtualAndHidingMethods();
                g.Main();
                break;

            case "8":
                var h = new OOP.AbstractClass();
                h.Main();
                break;

            case "9":
                var i = new OOP.SealedClass();
                i.Main();
                break;

            case "10":
                var j = new OOP.Interface();
                j.Main();
                break;

            case "11":
                var k = new OOP.Polymorphism();
                k.Main();
                break;
            }
        }