C# Interface Last Updated : 05 Apr, 2025 Comments Improve Suggest changes Like Article Like Report 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 interface’s members will be given by a class that implements the interface implicitly or explicitly. There are some important points to remember, as mentioned below:Interfaces cannot have private members.By default, all the members of Interface are public and abstract.The interface will always be defined with the help of the keyword interfaceInterfaces cannot contain fields because they represent an implementation of data.We can achieve multiple inheritance with the interface but not with the classes.We can implement multiple interfaces in a single class separated by commas.Example 1: Demonstrating the basic case for implementing the Interface. C# // Demonstrate working of Interface using System; interface inter1 { // method having only declaration // with no definition void display(); } // Implementing inteface in Geeks class Geeks : inter1 { // providing the body part of function public void display() { Console.WriteLine("Demonstration of interface"); } // Main Method public static void Main(String[] args) { Geeks t = new Geeks(); t.display(); } } OutputDemonstration of interface Example 2: Implementation of interfaces and the use of polymorphism in C# C# // Using Interfaces and Polymorphism using System; // interface declaration interface Vehicle { // abstract method. void speedUp(int a); } // class implements interface class Bicycle : Vehicle { int speed; // Method increase speed public void speedUp(int increment) { speed = speed + increment; } // Method check speed public void CheckSpeed() { Console.WriteLine("speed: " + speed); } } // class implements interface class Bike : Vehicle { int speed; // to increase speed public void speedUp(int increment) { speed = speed + increment; } public void CheckSpeed() { Console.WriteLine("speed: " + speed); } } class Geeks { public static void Main(String[] args) { // creating an instance of Bicycle // doing some operations Bicycle bicycle = new Bicycle(); bicycle.speedUp(3); Console.WriteLine("Bicycle present state :"); bicycle.CheckSpeed(); // creating instance of bike. Bike bike = new Bike(); bike.speedUp(4); Console.WriteLine("Bike present state :"); bike.CheckSpeed(); } } OutputBicycle present state : speed: 3 Bike present state : speed: 4 Advantages of InterfacesLoose coupling: It is used to achieve loose coupling rather than concrete implementations, we can decouple classes and reduce interdependencies.Abstraction: Interface helps to achieve full abstraction.Maintainability: It helps to achieve component-based programming that can make code more maintainable.Multiple Inheritance: Interface used to achieve multiple inheritance and abstraction.Define architecture: Interfaces add a plug and play like architecture into applications.Modularity: Promote a cleaner and more modular design. By separating the definition of behavior from the implementation Comment More infoAdvertise with us Next Article C# Interface M Mithun Kumar Follow Improve Article Tags : Misc C# CSharp-Interfaces Practice Tags : Misc Similar Reads C# - IDumpable Interface In this article, we will see how to implement IDumpable interface through C#. The IDumpable interface is just a simple interface which has a Dump() method and public property. Every class that wishes to implement the IDumpable interface has to implement the Dump() method and can make use of the publ 7 min read C# | Type.GetInterface() Method Type.GetInterface() Method is used to gets a specific interface implemented or inherited by the current Type. GetInterface(String) Method This method is used to search for the interface with the specified name. Syntax: public Type GetInterface (string name); Here, it takes the string containing the 4 min read C# | Inheritance in interfaces 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 nece 3 min read C# | Type.GetInterfaces() Method Type.GetInterfaces() Method is used to get all the interfaces implemented or inherited by the current Type when overridden in a derived class. Syntax: public abstract Type[] GetInterfaces ();Return Value: This method returns an array of Type objects representing all the interfaces implemented or inh 2 min read Delegates vs Interfaces in C# A Delegate is an object which refers to a method or you can say it is a reference type variable that can hold a reference to the methods. Delegates in C# are similar to the function pointer in C/C++. It provides a way which tells which method is to be called when an event is triggered. Example: CSha 3 min read C# | How to use Interface References In C#, you are allowed to create a reference variable of an interface type or in other words, you are allowed to create an interface reference variable. Such kind of variable can refer to any object that implements its interface. An interface reference variable only knows that methods which are decl 5 min read Default Interface Methods in C# 8.0 Before C# 8.0 interfaces only contain the declaration of the members(methods, properties, events, and indexers), but from C# 8.0 it is allowed to add members as well as their implementation to the interface. Now you are allowed to add a method with their implementation to the interface without break 5 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 Splint -- A C program verifier C compiler is pretty vague in many aspects of checking program correctness, particularly in type checking. Careful use of prototyping of functions can assist modern C compilers in this task. However, there is still no guarantee that once you have successfully compiled your program that it will run c 1 min read Unary Operators in C In C programming, unary operators are operators that operate on a single operand. These operators are used to perform operations such as negation, incrementing or decrementing a variable, or checking the size of a variable. They provide a way to modify or manipulate the value of a single variable in 5 min read Like