Wednesday, 27 July 2016

C Sharp Interface Tutorial

C# Interface Program

/* Error Code Attemt to multiple inheritance
     class a
    {
    }
    class b
    {
    }
    class c:a :b

    {
    }*/
    interface mathdemo
    {
        int  area(int x,int y) ;
        void display();
    }
    class test : mathdemo
    {
       public  void showtest()
        {
            Console.WriteLine("\nHi you're in test call function");
        }
       public  int area(int a,int b)
        {
            return a+b;
        }
       
      public   void display()
        {
            Console.WriteLine("\nFunction Implements by test class");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            //mathdemo ob = new mathdemo();
            //object or instance of an interface can not be created it can used by inheritance
            // it is mandatory to child class for implements interface function
            test ob = new test();
            Console.WriteLine("\nArea is {0}", ob.area(10, 20));
            ob.showtest();
            ob.display();
        }
    }
Next Topic