Delegates vs Interfaces in C# Last Updated : 05 Sep, 2023 Summarize Comments Improve Suggest changes Share 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 A ankita_saini Follow Improve Article Tags : Misc Difference Between C# CSharp-Interfaces CSharp-Delegates +1 More Practice Tags : Misc Similar Reads SQL Commands | DDL, DQL, DML, DCL and TCL Commands SQL commands are crucial for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will e 7 min read TCP/IP Model The TCP/IP model is a framework that is used to model the communication in a network. It is mainly a collection of network protocols and organization of these protocols in different layers for modeling the network.It has four layers, Application, Transport, Network/Internet and Network Access.While 7 min read Basics of Computer Networking A computer network is a collection of interconnected devices that share resources and information. These devices can include computers, servers, printers, and other hardware. Networks allow for the efficient exchange of data, enabling various applications such as email, file sharing, and internet br 14 min read Java Programs - Java Programming Examples In this article, we will learn and prepare for Interviews using Java Programming Examples. From basic Java programs like the Fibonacci series, Prime numbers, Factorial numbers, and Palindrome numbers to advanced Java programs.Java is one of the most popular programming languages today because of its 8 min read Unified Modeling Language (UML) Diagrams Unified Modeling Language (UML) is a general-purpose modeling language. The main aim of UML is to define a standard way to visualize the way a system has been designed. It is quite similar to blueprints used in other fields of engineering. UML is not a programming language, it is rather a visual lan 14 min read Second Largest Element in an Array Given an array of positive integers arr[] of size n, the task is to find second largest distinct element in the array.Note: If the second largest element does not exist, return -1. Examples:Input: arr[] = [12, 35, 1, 10, 34, 1]Output: 34Explanation: The largest element of the array is 35 and the sec 14 min read Python Lists In Python, a list is a built-in dynamic sized array (automatically grows and shrinks). We can store all types of items (including another list) in a list. A list may contain mixed type of items, this is possible because a list mainly stores references at contiguous locations and actual items maybe s 6 min read Introduction to Java Java is a high-level, object-oriented programming language developed by Sun Microsystems in 1995. It is platform-independent, which means we can write code once and run it anywhere using the Java Virtual Machine (JVM). Java is mostly used for building desktop applications, web applications, Android 4 min read f-strings in Python Python offers a powerful feature called f-strings (formatted string literals) to simplify string formatting and interpolation. f-strings is introduced in Python 3.6 it provides a concise and intuitive way to embed expressions and variables directly into strings. The idea behind f-strings is to make 5 min read Python Operators In Python programming, Operators in general are used to perform operations on values and variables. These are standard symbols used for logical and arithmetic operations. In this article, we will look into different types of Python operators. OPERATORS: These are the special symbols. Eg- + , * , /, 6 min read Like