Interface

Interface:

//interface method is public and abstract by default
using System;

namespace InterfaceTest
{

    public interface Drawable
    {
        void draw();
    }

    public class Rectangle : Drawable
    {
        public void draw()
        {
            Console.WriteLine("drawing rectangle...");
        }
    }


    public class Circle : Drawable
    {
        public void draw()
        {
            Console.WriteLine("drawing circle...");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Drawable d;
            d=new Rectangle();
            d.draw();
            d=new Circle();
            d.draw();

            Console.ReadKey();
        }
    }
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published.