Monday, 13 July 2015

[.]Dot Net Programs

 WRITE A PROGRAM to inherit base class into derived class (no method overriding

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication16
{
    class A
    {
        public void Say()
        {
            Console.WriteLine("say A");
        }
        public void Write()
        {
            Console.WriteLine("write A");
        }
    }
   class B : A
    {
        public void Say()
        {
            Console.WriteLine("say B");
        }
        public void Call()
        {
            Console.WriteLine("Call B");
        }
    }
    class Demo
    {
        static void Main(string[] args)
        {
            A a = new A();
            Console.WriteLine("Langston Hughes");
            a.Say();
            a.Write();
            //a.call(); // call() not accessible by A's abject
            Console.WriteLine("*Octavia Butler");
            B b = new B();
            b.Say();
            b.Write();
            b.Call();
            Console.WriteLine("--when (a=b)--");
            a = b;
            a.Say();
            a.Write();
            // a.Call(); // we cant call call() bcozz it is not defined by A class
           Console.ReadLine();
       }
    }

}