C# | Inheritance in interfaces Last Updated : 23 Aug, 2024 Comments Improve Suggest changes Like Article Like Report C# allows the user to inherit one interface into another interface. When a class implements the inherited interface then it must provide the implementation of all the members that are defined within the interface inheritance chain.Important Points: If a class implements an interface, then it is necessary to implement all the method that defined by that interface including the base interface methods. Otherwise, the compiler throws an error.If both derived interface and base interface declares the same member then the base interface member name is hidden by the derived interface member name.Syntax:// declaring an interfaceaccess_modifier interface interface_name { // Your code}// inheriting the interfaceaccess_modifier interface interface_name : interface_name{ // Your code}Example 1: CSharp // C# program to illustrate the concept // of inheritance in interface using System; // declaring an interface public interface A { // method of interface void mymethod1(); void mymethod2(); } // The methods of interface A // is inherited into interface B public interface B : A { // method of interface B void mymethod3(); } // Below class is inheriting // only interface B // This class must // implement both interfaces class Geeks : B { // implementing the method // of interface A public void mymethod1() { Console.WriteLine("Implement method 1"); } // Implement the method // of interface A public void mymethod2() { Console.WriteLine("Implement method 2"); } // Implement the method // of interface B public void mymethod3() { Console.WriteLine("Implement method 3"); } } // Driver Class class GFG { // Main method static void Main(String []args) { // creating the object // class of Geeks Geeks obj = new Geeks(); // calling the method // using object 'obj' obj.mymethod1(); obj.mymethod2(); obj.mymethod3(); } } OutputImplement method 1 Implement method 2 Implement method 3Example 2: CSharp // C# program to illustrate the concept // of inheritance in the interface using System; // declaring an interface public interface Votes { // method of interface void vote_no(int a); } // The methods of interface Votes // is inherited into interface Details public interface Details : Votes { // method of interface Details void detailsofauthor(string n, int p); } // Below class is inheriting // the interface Details // This class must implement // the methods of both interface // i.e. Votes and Details class TechnicalScriptWriter : Details { // implementing the method // of interface Votes public void vote_no(int a) { Console.WriteLine("Total number of votes is: {0}", a); } // implementing the method // of interface Details public void detailsofauthor(string n, int p) { Console.WriteLine("Name of the author is: {0}", n); Console.WriteLine("Total number of published" + " article is: {0}", p); } } // Driver Class class GFG { // Main method static void Main() { // Creating the objects of // TechinalScriptWriter class TechnicalScriptWriter obj = new TechnicalScriptWriter(); // calling the methods by passing // the required values obj.vote_no(470045); obj.detailsofauthor("Siya", 98); } } OutputTotal number of votes is: 470045 Name of the author is: Siya Total number of published article is: 98 Comment More infoAdvertise with us Next Article C# | Inheritance in interfaces A ankita_saini Follow Improve Article Tags : C# CSharp-OOP Similar Reads C# | Multiple inheritance using interfaces Introduction:Multiple inheritance refers to the ability of a class to inherit from multiple base classes. C# does not support multiple inheritance of classes, but it does supportmultiple inheritance using interfaces. An interface is a collection of abstract methods that a class can implement to prov 7 min read C# | Multilevel Inheritance Introduction: In object-oriented programming, inheritance is the ability to create new classes that are derived from existing classes, known as base or parent classes. Inheritance allows the derived classes to inherit properties and methods of the base classes and to add new features or functionalit 7 min read C# Inheritance Inheritance is a fundamental concept in object-oriented programming that allows a child class to inherit the properties from the superclass. The new class inherits the properties and methods of the existing class and can also add new properties and methods of its own. Inheritance promotes code reuse 6 min read C# | Explicit Interface Implementation An Interface is a collection of loosely bound items that have a common functionality or attributes. Interfaces contain method signatures, properties, events etc. Interfaces are used so that one class or struct can implement multiple behaviors. C# doesn't support the concept of Multiple Inheritance b 4 min read C# Interface An interface is defined using the interface keyword, similar to a class. An Interface is a blueprint that outlines a group of methods, properties, events, or indexers that a class or struct must implement. Unlike classes, it contains only the declaration of the members. The implementation of the int 3 min read Like