7/14/2010

C# Extending an interface



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExtendingAnInterface
{

    interface values
    {
        void input(int a,int b);
    }

    // extending an interface
    interface shape : values
    {

        void area();
    }

    class rect : shape
    {
        int l, w;

        public void input(int a, int b)
        {
            l = a;
            w = b;
        }

        public void area()
        {
            Console.WriteLine("length: " + l + " \n width: " + w);
            Console.WriteLine("Area of Rectangle: " + (l * w));
        }
    }



    class Program
    {
        static void Main(string[] args)
        {
            rect rt = new rect();
            rt.input(4, 5);
            rt.area();
        }
    }
}

No comments:

Post a Comment