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

    Why C# does not support multiple inheritance?

    Why C# does not support multiple inheritance?
  • #681228
    hi here is the some sample code see it
    assuming if multiple inheritance is supported in c#


    class A
    {
    protected void SampleMethod();
    }

    class A
    {
    protected void SampleMethod();
    }


    class C: A, B
    {

    }


    class MainClass
    {
    new C().SampleMethod(); //<--Here Which method to call now? A or B ?
    }


    In the above example, Since C inherits both A & B, there will to SampleMethod() in C. When you try to call SampleMethod on object c, there will conflict between which method to call.

    hope this will help you

  • #681238
    Hi,
    My dear Fried C# support multiple inheritance.

    Kindly reffer below like

    http://www.codeproject.com/Articles/10072/Simulated-Multiple-Inheritance-Pattern-for-C

    Regards
    Rameshwar

  • #681254
    dear Rameshwar

    for multiple inheritance in c# please refer this link hope you will understand

    http://www.c-sharpcorner.com/uploadfile/cbreakspear/multipleinheritance11082005004843am/multipleinheritance.aspx

  • #681257
    It supports multiple inheritance by interfaces only.
    Please refer,

    http://kiranpatils.wordpress.com/2008/03/10/why-c-doesn%E2%80%99t-supports-multiple-inheritance/


  • 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.