Using C# Delegates




c# delegates
C# Delegates

The concept of c# delegates brings the new feature that supports pointing or holding reference to the function in C# Programming World.
An important thing to be noted when using a delegate for a method that, it should contain the same return type or type of parameter(s), if any, that the addressed method is containing.

Why pointing by reference is more beneficial?

The concept of referencing by address is more beneficial than by referring by value because when some pointer holds the reference of a variable or a method with its address learned by it, it becomes quite efficient to invoke that method or use the variable (in case of C# pointers) for the memory management.
A real life example is finding the address of a person in order to meet him/her .
When a Delegate holds a reference to the method, it invokes that every time from that address, hence it also improves the method of following proper coding pattern by not writing the same method again and again when calling it number of times.

Delegate acts as the container of events

With that being said, a Delegate act as a Handler of event(s) in C#. Events in C# can be defined as the outcomes that occur when some action is performed.For example (pressing the button redirects the page to another page is the redirection event and pressing the button is an action

I have written a great article about the Delegates with detailed examples about their usage as a function pointer and as an event handler plus some interview related stuff in my own post. So don’t forget to read what I have written in my post here

Syed Adeel Ahmed on FacebookSyed Adeel Ahmed on GoogleSyed Adeel Ahmed on InstagramSyed Adeel Ahmed on Stumbleupon
Syed Adeel Ahmed
Syed Adeel Ahmed
Analyst, Programmer, Educationist and Blogger at Technofranchise
Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.

Published by

Syed Adeel Ahmed

Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.

Leave a Reply