Delegates vs Interfaces in C# Last Updated : 05 Sep, 2023 Comments Improve Suggest changes Like Article Like Report 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: CSharp // C# program to illustrate Delegates using System; class GFG { // Declaring the delegates public delegate void AddVal(int x, int y); public void SMeth(int x, int y) { Console.WriteLine("[{0} + {1}] = [{2}]",x,y, x + y); } // Main Method public static void Main(String[] args) { // Creating the object of GFG class GFG o = new GFG(); // Creating object of delegate AddVal obj = new AddVal(o.SMeth); // Pass the values to the method // Using delegate object obj(190, 70); } } Output[190 + 70] = [260] Like a class, Interface can have methods, properties, events, and indexers as its members. But interfaces will contain only the declaration of the members. The implementation of the interface’s members will be given by the class who implements the interface implicitly or explicitly. Example: CSharp // C# program to illustrate the // concept of interface using System; // A simple interface interface inter { // method having only declaration // not definition void display(); } // A class that implements the interface class Geeks : inter { // providing the body part of function public void display() { Console.WriteLine("Welcome to GeeksforGeeks..!"); } // Main Method public static void Main(String[] args) { // Creating object Geeks o = new Geeks(); // calling method o.display(); } } Output: Welcome to GeeksforGeeks..! Below are some differences between the Delegates and Interfaces in C#: DelegateInterfaceIt could be a method only.It contains both methods and properties.It can be applied to one method at a time.If a class implements an interface, then it will implement all the methods related to that interface.If a delegate available in your scope you can use it.Interface is used when your class implements that interface, otherwise not.Delegates can me implemented any number of times.Interface can be implemented only one time.It is used to handling events.It is not used for handling events.It can access anonymous methods.It can not access anonymous methods.When you access the method using delegates you do not require any access to the object of the class where the method is defined.When you access the method you need the object of the class which implemented an interface.It does not support inheritance.It supports inheritance.It can wrap static methods and sealed class methodsIt does not wrap static methods and sealed class methods..It created at run time.It created at compile time.It can implement any method that provides the same signature with the given delegate.If the method of interface implemented, then the same name and signature method override.It can wrap any method whose signature is similar to the delegate and does not consider which from class it belongs.A class can implement any number of interfaces, but can only override those methods which belongs to the interfaces. Comment More infoAdvertise with us Next Article Delegates vs Interfaces in C# ankita_saini Follow Improve Article Tags : Misc Difference Between C# CSharp-Interfaces CSharp-Delegates +1 More Practice Tags : Misc Similar Reads Multicast Delegates in C# A type-safe function pointer is a delegate. It means that the delegate contains a reference to a method or function, and that when we invoke the delegate, the method to which it refers will be executed. The delegate signature and the method to which it points must both be signed. The method must be 3 min read Java Class vs Interfaces In Java, the difference between a class and an interface is syntactically similar; both contain methods and variables, but they are different in many aspects. The main difference is, A class defines the state of behaviour of objects.An interface defines the methods that a class must implement.Class 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# - 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# Func Delegate In C#, a delegate is a type that references a method. When creating a custom delegate, we follow these steps:Declare a delegate with a signature matching the target method.Create an instance of the delegate.Invoke the method using the delegate.But defining custom delegates manually can be repetitive 3 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 Supplier Interface in Java with Examples The Supplier Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which does not take in any argument but produces a value of type T. Hence this functional interface takes in only one gener 1 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# Predicate Delegate A Predicate delegate is an in-built generic type delegate. This delegate is defined under System namespace. It works with those methods which contain some set of criteria and determine whether the passed parameter fulfill the given criteria or not. This delegate takes only one input and returns the 2 min read C# Delegates 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. It provides a way which tells which method is to be called when an event is triggered. For example, if you click on a Button on a form (Windows Form application), 6 min read Like