Can explain Delegates in Dotnet Framework
Loading
Can explain Delegates in Dotnet Framework
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sandhiya PriyaPosted Oct 27, 2025, 5:28 AM
What is a Delegate in .NET Framework?
A Delegate in C# is like a pointer to a function — it holds a reference to one or more methods with a specific signature and return type.
In simple words: A delegate is a type-safe function pointer that allows you to call methods indirectly.
Why Use Delegates?
Delegates are mainly used for:
Event handling (they are the base of Events)
Callback methods (methods passed as parameters)
Flexible code design (loose coupling between classes)
Syntax Example
Output:
How It Works
MyDelegatedefines the method signature (void, string).ShowMessagematches that signature.delstores a reference toShowMessage.When
del()is called ? it runsShowMessage().Types of Delegates
Multicast Example
Output:
Common Built-in Delegates
Key Points
Delegates are type-safe (method signature must match).
They enable loose coupling between sender and receiver.
Used extensively in events, LINQ, and async programming.
In Short
Delegate = A variable that holds a reference to a method.
Event = A notification mechanism based on a delegate.
Amit MohantyPosted Jun 3, 2025, 5:15 AM
A delegate is a type-safe function pointer in .NET. It holds a reference to one or more methods that match its signature and return type. Think of it as a reference to a method with a specific signature.
Syntax of a delegate:
This defines a delegate type called MathOperation that can reference any method that takes two int parameters and returns an int.
How to use Delegate:
RinkiPosted Jun 2, 2025, 6:34 AM
Delegates are a type-safe way to define and use function pointers. They are especially useful for event handling and callback methods.
You can read more here - https://www.c-sharpcorner.com/article/what-is-delegates-in-c-sharp-net/