Skip to content

Multiple inheritance

Mohit Pandey

Mohit Pandey

Asked Jul 23, 2014, 5:01 AM EDT1 answer
Share
LinkedInX
what is multiple inheritance ?  what  use of  interface in multiple inheritance ?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Inheritance : Creating a new class from existing class is known as Inheritance. Main purpose is reusability of code. New class is known as Derived(Child) class and already exiting class is known as Base(Parent) class.

    In dotnet we have 
    1)Simple
    2)Multi level 
    3)Heirarchical
    4)Hybrid

    but in dotnet we not having multiple inheritance means deriving a new class from several base classes.

    To overcome this Interfaces are introduced.

    Interface: An interface looks like a class, but has no implementation. The only thing it contains are declarations of events, indexers, methods and/or properties. The reason interfaces only provide declarations is because they are inherited by classes and structs, which must provide an implementation for each interface member declared

    Interface interface1
    {
    method1();
    }
    Interface intrface2
    {
    method2();
    }

    public class Test:interface1,interface2
    {
    //logic
    }

    And so much other uses also there 


    Please accept answer if it helps to you :)
    0