This article is introducing a new reference type, delegate. A delegate is a C# language element that allows programmers to reference a method for their development work.
We have all learned how to implement reference types using language constructs like:
These reference types allow programmers to create instances of objects and use them in special ways for development procedure purposes.Classes allow us to create objects that contain members with attributes or functionality. While on the other hand the interface allows us to declare a set of attributes and behavior that all objects are implementing for exposing them publicly or privately.Now I am introducing a new reference type, "delegate".A delegate is a C# language element that allows programmers to reference a method for their development work. Generally C or C++ programmers are much more familiar with the concept of delegates in comparison to others.C# Delegates Features
C# Delegates DescriptionDelegates provide flexibility and scalability, so that it can be used consistent with the requirements or goals of your development procedure. There are fewer boundary limitations with delegates. Interfaces also can be used instead of delegates but due to some extra functionality programmers do prefer delegates instead of other reference methods. C# Delegates DeclarationDeclaration of delegates is somewhat similar to methods. Except that a delegate has the extra feature of a delegate modifier. A delegate modifier is terminated with a semicolon (;) and requires no implementation. For example:public delegate int Comparer(object obj1, object obj2)C# Delegates Delegate HandlerA delegate handler method works as follows:
Reference Example
Diving Into OOP