static void Main(string[] args)
        {
            derivedclass objD = new derivedclass();
            baseClass    objB = new baseClass();

            objD.add(1, 2);                        //calls the derived class's add method
            objB.add(1, 2);                        //calls the base class's add method
            baseClass    ob  = new derivedclass(); // this is not possible because we have an overriden method in Deviverclass throws error
            derivedclass ob2 = new baseClass();    // to access base call method with out creating a new instance of the base class
        }
예제 #2
0
        static void Main()
        {
            //calling the methods of the class "program" by creating an instance of it instead of inheriting it
            baseClass proObj = new baseClass();

            //all the possible methods that can be called

            proObj.internalMethod();
            proObj.PublicMethod();
            proObj.ProtectedInternalMethod();

            // methods except private protected can be called
        }
예제 #3
0
        static void Main(string[] args)
        {
            baseClass obj = new baseClass();

            //all possible methods that can be called

            obj.internalMethod();
            obj.PrivateMethod();
            obj.ProtectedInternalMethod();
            obj.PublicMethod();
            obj.ProtectedMethod();
            //all the methods can be called

            Console.ReadLine();
        }