1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to create multiple inheritance in c# and .NET?

Discussion in 'C#' started by raspms, Mar 14, 2012.

  1. #1
    hello,
    can anybody tell me how to create multiple inheritance in C# and in asp.net?
     
    raspms, Mar 14, 2012 IP
  2. initiotech

    initiotech Well-Known Member

    Messages:
    187
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #2
    C# Does not support Multiple Inheritance...It supports multiple Interface Implementations...

    Example For implementing multiple interfaces

    There are workaround which help you inherit multiple classes in a class...but Multiple Inheritance in one class is not possible without the use of Interfaces ...
     
    initiotech, Mar 19, 2012 IP
  3. Vivianflo

    Vivianflo Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah C# and Asp.net does not support multiple inheritance. It only supports Single or multilevel inheritance.
     
    Vivianflo, Mar 29, 2012 IP
  4. pankaj.go

    pankaj.go Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Suppose Multiple Inheritance were allowed
    We have two class (ClassA and ClassB) with a same method name.
    Now we inherit the ClassC from both the class. Now we will fall in situation where we do not know who's who?

    To avoid this confusion .net along with other OOP based programming languages doesn't allow MI.
     
    pankaj.go, Apr 9, 2012 IP
  5. rok86

    rok86 Greenhorn

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    multiple Inheritance in ASP.NET is done through interface as given below :

    interface ISampleInterface
    {
    void SampleMethod();
    }

    class ImplementationClass : ISampleInterface
    {
    // Explicit interface member implementation:
    void ISampleInterface.SampleMethod()
    {
    // Method implementation.
    }

    static void Main()
    {
    // Declare an interface instance.
    ISampleInterface obj = new ImplementationClass();

    // Call the member.
    obj.SampleMethod();
    }
    }
     
    rok86, Apr 20, 2012 IP
  6. amitets

    amitets Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    C# is an object oriented language and any object oriented language does not support multiple inheritance,it supports multiple interface implementation.
     
    amitets, Jun 27, 2012 IP
  7. agitetech

    agitetech Peon

    Messages:
    122
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yes,agree with the mates C# does not allow multiple inheritance but you can do it by implementing Multiple Interfaces
     
    agitetech, Dec 26, 2012 IP
  8. miguelf

    miguelf Member

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    48
    #8
    You can't. C# is single inheritance use interfaces.
     
    miguelf, Jan 15, 2013 IP
  9. annaharris

    annaharris Active Member

    Messages:
    119
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    51
    #9
    You can use interface in C#. It doesn't support multiple inheritance as it is an object oriented programming language.
     
    annaharris, Mar 29, 2013 IP
  10. alendonald

    alendonald Greenhorn

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #10
    Yes C#, and Asp.Net not support Multiple Inheritance.
     
    alendonald, Jul 8, 2013 IP
  11. cooljeba

    cooljeba Well-Known Member

    Messages:
    570
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    160
    #11
    I am really interested in knowing in which scenario are you planning to implement multiple inheritance ?
     
    cooljeba, Aug 6, 2013 IP
  12. zinist

    zinist Banned

    Messages:
    91
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    43
    #12
    C# does not support multiple inheritance, so to overcome this problem Microsoft introduce interface you can implement multiple interfaces
     
    zinist, Jun 26, 2015 IP