Exemplo n.º 1
0
        private static void Main()
        {
            /*---- base class object -------*/
            baseclass bObj = new baseclass();

            //b.privatefield = 9;         //From outside the class, we can't access private stuff
            //b.protectedfield = 9;       //From outside the class, we can't access protected stuff
            bObj.publicField = 9;

            //b.privateMethod();
            //b.protectedMethod();
            bObj.publicMethod();


            /*---- Derived class object -------*/
            derivedClass dObj = new derivedClass();

            //d.privatefield = 9;       //From outside the class, we can't access private stuff
            //d.protectedfield = 9;     //From outside the class, we can't access protected stuff
            dObj.publicField = 9;          //Everyone can access public stuff

            //d.privateMethod();         //From outside the class, we can't access private stuff
            //d.protectedMethod();        //From outside the class, we can't access protected stuff
            dObj.publicMethod();            //Everyone can access public stuff
        }
Exemplo n.º 2
0
        private static void Main()
        {
            derivedClass d = new derivedClass();

            //d.privatefield = 9;
            //d.protectedfield = 9;
            d.publicField = 9;

            //d.privateMethod();
            //d.protectedMethod();
            d.publicMethod();


            baseclass b = new baseclass();

            //b.privatefield = 9;
            //b.protectedfield = 9;
            b.publicField = 9;

            //b.privateMethod();
            //b.protectedMethod();
            d.publicMethod();
        }