programming-examples/c-sharp/Delegates/C# Program to Display Results using Delegates..txt
2019-11-15 12:59:38 +01:00

27 lines
553 B
Plaintext

/*
* 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();
}
}
public class Results
{
public int sum(int a, int b)
{
return a + b;
}
}
/*
Result is: 70