Monday, 13 July 2015

[.]Dot Net Programs

WRITE A PROGRAM to show multiple inheritance using class and interface.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication19
{
    class A
    {
        public virtual void Show()
        {
            Console.WriteLine("Show A");
        }
        public void Disp() { }
    }
    interface Z
    {    void Call();
    }
    class B : A, Z
    {
        public override void Show()
        {
            Console.WriteLine("Show B");
        }
        public void Call()
        {
            Console.WriteLine("Call B");
        }
    }
      class Demo
      {
        static void Main(string[] args)
        {
            B b = new B();
            Console.WriteLine("----B---");
            b.Show(); // will call show() of B class
            b.Call(); // will call call() of B class
            A a = b;
            Console.WriteLine("---(A=B)--");
            a.Show(); // will call show() of B class
            Console.ReadLine();
        }
    }

}