You must Sign In to post a response.
  • Category: .NET

    Multiple interfaces in C#.net

    Can you inherit multiple interfaces? give an example
  • #648387
    Hi,
    Yes we can Inherit Multiple Interface .

    Check below code so that you can get it:



    public class DumpTruck : IEngine, IBody
    {
    void IEngine.Test()
    {
    Console.WriteLine("This is the Engine TEst");
    }
    void IBody.Test()
    {
    Console.WriteLine("This is the Body TEst");
    }
    }


    With Regards
    Kushal

  • #648420
    hi


    interface I1
    {
    void method1();
    }
    interface I2
    {
    void method2();
    }
    public class Demo: I1, I2
    {
    void method1()
    {
    Console.WriteLine("Implementation for method1");
    }
    void method2()
    {
    Console.WriteLine("Implementation for method2");
    }
    }

    Regards
    Sagar pawar
    Software developer

  • #648444
    Hello,

    please check below code:


    using System;
    public interface Car
    {

    void shape();
    void Color();

    }



    public interface CShape
    {

    void Square();
    void trangle();

    }
    // Car class implements the interfaces
    class Car1 : Car, CShape
    {


    private bool shapeed = false;


    public void shape()
    {


    }


    public void Color()
    {


    }



    public void Square()
    {

    }


    public void trangle()
    {

    }

    }

    Regards
    Mr.Rajesh
    Software Engg.


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.