This C# program displays the results, using Delegates. Here, Delegate is a type, which holds the method(s) reference in an object. It is also referred to as a type safe function pointer.
Here is the source code of the C# program to display the results, using Delegates. C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
Program
Here is the source code of the C# program to display the results, using Delegates. C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
Program
- /*
- * C# Program to Display Results using Delegates
- */
- using System;
- public class example
- {
- public delegate int DelegateHandler(int a, int b);
- static void Main(string[] args)
- {
- Results Results = new Results();
- DelegateHandler sum = new DelegateHandler(Results.sum);
- int result = sum(50, 20);
- Console.WriteLine("Result is: " + result);
- Console.ReadLine();
- }
- }
Output


Chittaranjan SwainPosted Oct 19, 2019, 3:49 AM
Nice one....
Hariharan KrishnamoorthiPosted Jun 7, 2017, 6:24 AM
Public class Results{ public int sum(int a, int b) { return a + b; } }
Muthuramalingam DuraipandiPosted Mar 31, 2017, 5:57 AM
Nice Share ....doing well
Jhonathan SoaresPosted Mar 6, 2017, 2:05 PM
The original article wroted in 2014! http://www.sanfoundry.com/csharp-program-results-delegates/